#9 dotnet restore fails for new project
Closed by bslbckr. Opened by bslbckr.

I'm running Fedora31 Silverblue and use toolbox to setup different development environments. One of these environments is for dotnet development and hence I enabled the dotnet-sig copr and installed dotnet-sdk-3.0.
However, I'm unable to do any task related to dotnet restore as this reproducibly yields the following error:

[bb@toolbox validation]$ dotnet restore
/usr/lib64/dotnet/sdk/3.0.100/NuGet.targets(123,5): error : '31 (Container Image)' is not a valid version string. (Parameter 'value') [/var/home/bb/*****.csproj]

The output of dotnet --info is:

[bb@toolbox validation]$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26
Runtime Environment:
 OS Name:     fedora
 OS Version:  31
 OS Platform: Linux
 RID:         fedora.31-x64
 Base Path:   /usr/lib64/dotnet/sdk/3.0.100/
Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33
.NET Core SDKs installed:
  3.0.100 [/usr/lib64/dotnet/sdk]
.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.0.0 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.0 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

the project-file I tried to restore is as minimal as it could be:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
</Project>

Toolbox version is: 0.0.18-1.fc31.noarch
dotnet package is: dotnet-sdk-3.0-3.0.100-5.fc31.x86_64

Is there anything I can configure / check in order to further investigate this error?


The error strings contains this very interesting bit: '31 (Container Image)'. Any ideas where that comes from? What does cat /etc/os-release tell you?

If I run it directly on the host:

bb@linux ~]$ cat /etc/os-release 
NAME=Fedora
VERSION="31.20200224.0 (Workstation Edition)"
ID=fedora
VERSION_ID=31
VERSION_CODENAME=""
PLATFORM_ID="platform:f31"
PRETTY_NAME="Fedora 31.20200224.0 (Workstation Edition)"
ANSI_COLOR="0;34"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:31"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f31/system-administrators-guide/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=31
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=31
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Workstation Edition"
VARIANT_ID=workstation
OSTREE_VERSION='31.20200224.0'

If I run it inside the toolbox container:

[bb@toolbox validation]$ cat /etc/os-release 
NAME=Fedora
VERSION="31 (Container Image)"
ID=fedora
VERSION_ID=31
VERSION_CODENAME=""
PLATFORM_ID="platform:f31"
PRETTY_NAME="Fedora 31 (Container Image)"
ANSI_COLOR="0;34"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:31"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f31/system-administrators-guide/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=31
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=31
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Container Image"
VARIANT_ID=container

I think we found the source for the 31 (Container Image) string.

Can you do an env? Does it include the VERSION variable with the value 31 (Container Image)?

I can trigger a very similar issue on my end using Fedora 31 (not a VM/container) using:

$ export VERSION='31 (Container Image)'
$ dotnet new console
...
Processing post-creation actions...
Running 'dotnet restore' on /home/omajid/temp/hello/hello.csproj...
/usr/lib64/dotnet/sdk/3.1.101/NuGet.targets(123,5): error : '31 (Container Image)' is not a valid version string. (Parameter 'value') [/home/omajid/temp/hello/hello.csproj]
...

If that's the case, does an unset VERSION fix the issue?

Yes, if I run env I see exactly the mentioned value for version:

[bb@toolbox ~]$ env
SHELL=/bin/bash
COLORTERM=truecolor
HISTCONTROL=ignoredups
XDG_MENU_PREFIX=gnome-
HISTSIZE=1000
HOSTNAME=toolbox
DOTNET_ROOT=/usr/lib64/dotnet
SSH_AUTH_SOCK=/var/run/user/1000/gnupg/S.gpg-agent.ssh
DISTTAG=f31container
DESKTOP_SESSION=gnome
NAME=Fedora
XDG_SESSION_DESKTOP=gnome
XDG_SESSION_TYPE=wayland
TOOLBOX_PATH=/usr/bin/toolbox
container=oci
LANG=C.UTF-8
XDG_CURRENT_DESKTOP=GNOME
FGC=f31
COLUMNS=80
VTE_VERSION=5803
WAYLAND_DISPLAY=wayland-0
TERM=xterm-256color
VERSION=31 (Container Image)

Changing the value of VERSION using either unset or VERSION=31 dotnet restore solved the issue.
I think the issue is not related to dotnet but probably an issue that should be considered in the context of toolbox.
Thank's very much for your kind support.

Metadata Update from @bslbckr:
- Issue status updated to: Closed (was: Open)

I think this is a generic .NET/msbuild issue. msbuild reads all environment variables (such as the extremely generic VERSION) and uses them to initialize project properties. This can lead to any random environment variable conflicting with an msbuild property and producing a funny result. You can read more about it here: https://github.com/microsoft/msbuild/issues/2713

Thank's again for pointing this out.
I just found another workaround: If I set the version property inside the project-file the error doesn't occur.

Metadata