After installing Visual Studio 2017 Update 15.3 and the .NET Core 2.0 SDK I thought I was finally ready to ‘upgrade’ some of my projects to .NET Standard 2.0.
I right clicked on my project, selected Properties and tried to change the Target Framework on the Application tab. Unfortunately I didn’t see a .NET Standard 2.0 option in the list.
OK, let’s try a different approach. I right clicked on the project and choose Edit .csproj file and updated the TargetFramework to netstandard2.0 directly in the project file
This worked but resulted in a set of strange error messages when I tried to compile a .NET Core project that was referencing this library.
In the end it turned out that I had a global.json file that was the root cause of my problems. The global.json file defines which version of the .NET Core SDK to use:
{ "sdk": { "version": "1.0.0" } }
When you rundotnet new
ordotnet build
, thedotnet
host looks in the current folder,and all parent folders for a global.json. If a global.json exists (and the SDK version it references exists!) then that version will be used for all SDK commands. If not, it will just use the newest version of the SDK.
I removed the global.json and not only did my build errors disappeared, when I opened the project properties again I could now select .NET Standard 2.0: