Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NuGet Invalid Version String - on Linux when os-versions includes a space in the version #5742

Open
nkolev92 opened this issue Sep 17, 2020 · 5 comments
Labels

Comments

@nkolev92
Copy link

@shyzus commented on Tue, 01 Sep 2020 01:47:50 GMT

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): dotnet

NuGet version (x.x.x.xxx): 5.4.0.2

dotnet.exe --version (if appropriate): 3.1.106

VS version (if appropriate): N/A

OS version (i.e. win10 v1607 (14393.321)): Fedora 32.20200831.0 (Silverblue)

Worked before? If so, with which NuGet version: N/A

Detailed repro steps so we can see the same problem

  1. Create toolbox in silverblue with:
    toolbox create --container dotnet-toolbox

  2. Enter toolbox:
    toolbox enter dotnet-toolbox

  3. Install required packages:
    sudo dnf install dotnet-sdk-3.1 dotnet-host dotnet dotnet-templates-3.1 dotnet-targeting-pack-3.1 dotnet-apphost-pack-3.1 dotnet-build-reference-packages mono-devel

  4. Create a new Command Line Application
    mkdir MyConsoleApp
    cd MyConsoleApp
    dotnet new console

  5. Attempt to build
    dotnet build

Other suggested things

This can be solved with a hotfix for other Silverblue users by modifying their /etc/os-release file and removing any whitespaces and any parenthesis e.g "()".

However I would suggest whatever code is determining whether a version is valid or invalid is updated to permit whitespaces and/or parenthesis. I am not aware of any issues this change would cause and would like to see this change implemented.

Logs

Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

/usr/lib64/dotnet/sdk/3.1.106/NuGet.targets(123,5): error : '32 (Container Image)' is not a valid version string. (Parameter 'value') [/var/home/falcon/RiderProjects/consoleapp/consoleapp.csproj]

Build FAILED.

/usr/lib64/dotnet/sdk/3.1.106/NuGet.targets(123,5): error : '32 (Container Image)' is not a valid version string. (Parameter 'value') [/var/home/falcon/RiderProjects/consoleapp/consoleapp.csproj]
0 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.46

Sample Project

See step 3.

Edited: Added missing step

@nkolev92
Copy link
Author

@rrelyea commented on Fri, 04 Sep 2020 23:10:02 GMT
@shyzus - since I don't have SilverBlue around...can you tell us one thing?

A) what is the content in that older version of the SDK in NUGet.Targets around line 123 (which raised the error).
B) does this also repro if you call "dotnet restore" ... or only if you call dotnet build?
C) can you increase the verbosity to see more details of the error?
D) this is likely a call from NuGet to NetCore runtime..unsure how we would use this.

Looks like https://www.man7.org/linux/man-pages/man5/os-release.5.html specifies that a space and parens can be there such as: "32 (Container Image)" --

@nkolev92
Copy link
Author

@shyzus commented on Thu, 10 Sep 2020 02:18:45 GMT
@rrelyea Thanks for responding and sorry for the late reply.

A) It seems to be a call to restore, see the snippet below:

<RestoreTask
      RestoreGraphItems="@(_RestoreGraphEntryFiltered)"
      RestoreDisableParallel="$(RestoreDisableParallel)"
      RestoreNoCache="$(RestoreNoCache)"
      RestoreIgnoreFailedSources="$(RestoreIgnoreFailedSources)"
      RestoreRecursive="$(RestoreRecursive)"
      RestoreForce="$(RestoreForce)"
      HideWarningsAndErrors="$(HideWarningsAndErrors)"
      Interactive="$(NuGetInteractive)"
      RestoreForceEvaluate="$(RestoreForceEvaluate)"/>
  </Target>

B) Yes when executing dotnet restore the same error description is given, see the snippet below:

/usr/lib64/dotnet/sdk/3.1.106/NuGet.targets(123,5): error : '32 (Container Image)' is not a valid version string. (Parameter 'value') [/var/home/falcon/RiderProjects/consoleapp/consoleapp.csproj]

C) Yes, I have run the command dotnet restore --verbosity diagnostic and placed the result into a log file:
error.log

D) If this isn't the appropriate project to submit this issue to, il gladly try and transfer it to the one you believe is appropriate.

Edit: Grammer and spelling

@nkolev92
Copy link
Author

@zkat commented on Thu, 10 Sep 2020 18:00:31 GMT
It looks like this is happening due to the $VERSION env variable being set, which is used by msbuild, which initializes properties with env vars (see #2713).

Even if we fix the NuGet side of this, it's likely you'll just run into a separate build error anyway. Is it possible to just remove/clear that environment variable? That might be enough to get this working for you.

@nkolev92
Copy link
Author

@shyzus commented on Sat, 12 Sep 2020 16:52:06 GMT
@zkat Well I am not certain how I would go about preventing $VERSION from being set. But I have tried out modifying my /etc/os-release file as mentioned in my primary post. This allowed me to successfully use dotnet restore and successfully build and run the basic hello world CLI project generated by dotnet new console.

It would seem to be that there are some checks within the restore command that prevent it from running successfully if certain characters are present in the VERSION variable of my /etc/os-release file.

@nkolev92
Copy link
Author

@nkolev92 commented on Thu, 17 Sep 2020 17:24:28 GMT
Hey @shyzus,

The behavior here is driven by an MSBuild feature where environment variables are translates to properties. See: https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-use-environment-variables-in-a-build?view=vs-2019.

Given that the decision is coming from MSBuild moving to their repo and they'll be able to answer more questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants