Note: I use VS 2019 Professional Version 16.0.2

Problem: I have a source code base working perfectly fine in VS 2017. But to support .NET core 3.1, I have decided to upgrade my VS 2017 to VS 2019. When I open-source code in VS 2019. It's not showing .NET Standard 2.1 and .NET Core 3.1 as part of Target Framework. When I look for project properties.

When I modify .csproj file with <TargetFramework>netcoreapp3.1</TargetFramework> and then build I get:

The current .NET SDK does not support targeting .NET Core 3.1. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 3.1.

For another project, When I modify the .csproj file with <TargetFramework>netstandard2.1</TargetFramework> and then build I get:

The current .NET SDK does not support targeting .NET Standard 2.1. Either target .NET Standard 2.0 or lower, or use a version of the .NET SDK that supports .NET Standard 2.1.

What I have tried:

  1. Now I decided to create a brand new project in VS 2019. Then the the surprising thing is it just shows me .NET Standard 2.1 and .NET Core 3.1 as part of Target Framework.
  2. Also looking at the previous StackOverflow answers. I have created the global.json file at the top of my solution. global.json look like

{ "sdk": { "version": "3.1.402" } }

but I as part of my solution. I have 2 projects. The first project is netstandard and the second project is netcore [my test project is netcore]. The test project allows me to select 3.1 from the project property target framework section but my first project is not able to show me netstandard2.1 as part of the project property target framework. Did my global.json is wrong?

Expectation: My source code which is building perfectly on VS 2017 should have been building on VS 2019.

Actual

1

There are 1 answers

0
sushil On

Answer to my question:

  1. Update VS 2019 - I was using VS 2019 16.0.2 professional (by default triggered by IT). To solve my issue, I need to update VS 2019 to 16.4 because it includes .NET Core 3.1.
  2. Update .sln file: I need to do this because my source code was developed using vs2017 that's why my .sln file was according to VS2017. VS 2019 will use MSBuild 16. Make sure .sln should have an entry for VisualStudioVersion = 16.. (To generate this you can create a dummy project application with VS2019 and then compare your project .sln file with the generated VS2019 .sln file you will see the difference)

NOTE: Also, make sure if you are using .NET Core 2.1 SDK then install v2.1.810 which is meant for VS2019.