Bug 60574 - msbuild falls back to .NET Standard 1.6.1 when targeting 2.0
Summary: msbuild falls back to .NET Standard 1.6.1 when targeting 2.0
Alias: None
Product: Tools
Classification: Mono
Component: msbuild ()
Version: unspecified
Hardware: PC Mac OS
: High normal
Target Milestone: ---
Assignee: Ankit Jain
Depends on:
Reported: 2017-11-08 18:00 UTC by David Karlaš
Modified: 2017-11-14 12:31 UTC (History)
6 users (show)

Is this bug a regression?: ---
Last known good build:

SampleProject (2.11 KB, application/zip)
2017-11-08 18:00 UTC, David Karlaš

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description David Karlaš 2017-11-08 18:00:17 UTC
Created attachment 25610 [details]

If .NET Core 2.0 is not installed it's not possible to compile .NET Standard 2.0 project.
See attached sample and try to compile with `msbuild`. It will fail because `Assembly` property is not part of `System.Type`, which is not true for 2.0, reason for this is that building falls back to .NET Standard 1.6.1 this can be seen in msbuild output(it's referencing 1.6.1 assembles and in obj/project.assets.json it shows that 1.6.1 is used and not 2.0.
Comment 1 Matt Ward 2017-11-14 09:47:33 UTC
When I tried this on Windows with just .NET Core 1 SDK installed it had the same problem. It seems that the .NET Core 1.1 sdk does not indicate an error if an unsupported .NET Standard version is used with it and it just silently downgrades the .NET Standard Library package reference which may or may not be caught by the code that is used.

I also am not sure if we should be shipping .NET Core 2.0 sdk with Mono since MSBuild will now resolve it if it is installed. This was not the case with .NET Core 1.1 sdk so it is shipped with Mono.

Ideally I think the .NET Core 1.1 sdk would indicate an error if an unknown/unsupported version of .NET Standard is being used in the project.
Comment 2 Marek Safar 2017-11-14 11:29:22 UTC

Could you report this netstandard/netcore on issues tracker?
Comment 3 David Karlaš 2017-11-14 11:39:15 UTC
I still think Mono should support .NET Standard 2.0 without installing .NET Core.
Comment 4 Matt Ward 2017-11-14 12:31:32 UTC
This seems to already be handled by .NET Core 1.1.4 SDK. If you run `dotnet restore` on a .NET Standard 2.0 sdk project with only .NET Core SDK 1.1.4 installed you seen an error:

dotnet restore
/usr/local/share/dotnet/sdk/1.1.4/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.TargetFrameworkInference.targets(126,5): error : The current .NET SDK does not support targeting .NET Standard 2.0.  Either target .NET Standard 1.6 or lower, or use a version of the .NET SDK that supports .NET Standard 2.0. [~/Projects/Tests/dotnet/dotnet.csproj]