Visual Studio 2019 Not Showing .NET 6 Framework

Viewed 92264

I've been struggling to change an asp.net core web api project's target framework to .NET 6 which was started using target framework .net5. I've already tried a few options but couldn't find the .NET 6 framework listed in the target dropdown.

  1. I am using Microsoft Visual Studio Enterprise 2019 Version 16.11.3.
  2. I've installed .NET 6.0.0-rc.2.21480.5. which is verified through dotnet --version.
  3. Enabled "Use previews of the .NET Core SDK", and restarted the program.
  4. restarted workstation several times & still no luck.

Looking forward to availing of community help!

11 Answers

.NET 6 is not supported in VS2019. You might make it work by manually editing your project file, but for a fully supported experience you should upgrade to VS2022.

You don't need to use the dropdown - open your .csproj file and change target framework manually:

<TargetFramework>net6.0</TargetFramework>

As for dropdown - it seems that there is some bug in VS - I have 16.11.5 installed alongside VS 2022 preview and the "Use previews of the .NET Core SDK" flag enabled and even project using .NET 6 (which builds and runs via VS2019). Also despite missing .NET 6 in the project properties the new project wizard has it.

P.S. Submitted an issue for Visual Studio.

UPD

Visual Studio 2019 does not support .NET 6 (also see VS support in the release notes). Install VS 2022 for full .NET 6 support.

To get Visual Studio 2019 to work with .NET 6 all you have to do is the following:

  • Install the .NET 6 SDK: https://dotnet.microsoft.com/download
  • Open your VS project that you want to switch to .NET 6
  • Build your project with .NET 5(+)
  • go into the project dir and find your project file: .csproj
  • open the project file in notepad or Notepad++, basically any txt editor and find the node: <TargetFramework>
  • If you built your project with .NET 5(+) it will read as: <TargetFramework>net5.0-windows</TargetFramework>
  • Simply switch the value to: net6.0-windows 5 changed to 6
  • Your TargetFramework entry should be edited to: <TargetFramework>net6.0-windows</TargetFramework>
  • Now save your project file
  • Next simply boot up Visual Studio 2019 and the target project you just modified to run .NET 6.
  • Do a clean on your project under the [ Build ] menu item
  • Now re-build your project and you are good to go \m/ :) \m/

Note I am using a Windows platform example the same concept should work for Linux etc just look at what the .NET 5 node looks like for the <TargetFramework> and just swap in the 6 instead of 5 and keep what ever other txt is in the value. I have not tried other platforms other than Windows but I am sure it will work as well.

I have swapped various projects and complicated ones and .NET 6 works perfectly in all cases on Visual Studio 2019! I personally will get Visual Studio 2022 as soon as I can but am very happy I can start .NET 6 development on day one on VS2019 till I can upgrade to 64bit goodness and Hot Reloading etc.

Anyways I hope this helps someone.

Update Visual Studio to Vs2019 16.11.7 My Problem solved But First you have to Check the Checkbox: Tools>Options>Environment>Preview Features>Use Preview Of .Net SDK(requires restart)

According to Microsoft resources, you can only use dot net core 6 Preview-1, 2, 3 And 4 in Visual Studio 2019. this link

.NET 6.0 is coming with VS 2022 ,install the new visual studio version and proceed

Another potential reason might be a global.json, I forgot we had one and it prevented .NET 5/6 from showing up in the dropdown. As soon as I fixed that by pointing it to the new version, it showed up.

For me the cause was the 32 bit(!) installation of dotnet.exe in the c:\Program Files (x86)\... folder.

What I've done?

  • As a diagnostic step I run dotnet --list-sdks, it listed nothing
  • Although I was convinced I have dotnet sdks (I working daily basis with .NET, and now installed VS 2022, how it would be possible not having any SDKs?
  • Anyway, I installed the latest release of .NET 6 SDK
  • As a diagnostic step I run dotnet --list-sdks, still nothing
  • I run where dotnet.exe and it turned out that it came from c:\Program Files (x86)\...
  • Renamed the 32 versions folder, and all solved.

You must edit the file %PROGRAMFILES%\dotnet\sdk\[VERSION]\minimumMSBuildVersion with version of msbuild supported by VS 2019.

.NET SDK 6.0.100 is almost correctly working with Visual Studio 2019 v16.10.3. Microsoft lies that it is VS 2022-only. :) Theoretically, newer versions should work too, but some people saying that it was broken near VS 16.11.10 or in latest .NET 6.0.x SDKs (correct me, please, if it is not). I currently haven't checked.

To set target .NET runtime version to 6.0, enter <TargetFramework>net6.0</TargetFramework> version in project's .csproj file directly. This will give empty dropdown list line in project's properties window, but, however, the project will build for .NET 6.0. This means also that all projects, initially written for .NET 6, should open on VS 2019 too (if they don't use new C# 10 features).

When building the project under Visual Studio (not via dotnet command line), it will add warning NETSDK1182: Targeting .NET 6.0 in Visual Studio 2019 is not supported message. It does not break compiling and debugging, but can be easily thrown out too. Open .csproj file again, and add <NoWarn>$(NoWarn);NETSDK1182</NoWarn> to an PropertyGroup.

Related