'Visual Studio 2019 Not Showing .NET 6 Framework
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.
- I am using Microsoft Visual Studio Enterprise 2019 Version 16.11.3.
- I've installed .NET 6.0.0-rc.2.21480.5. which is verified through dotnet --version.
- Enabled "Use previews of the .NET Core SDK", and restarted the program.
- restarted workstation several times & still no luck.
Looking forward to availing of community help!
Solution 1:[1]
.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.
Solution 2:[2]
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.
Solution 3:[3]
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.
Solution 4:[4]
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)
Solution 5:[5]
Dotnet 6.0 is only supported in visual studio 2022. you can check details from here: https://dotnet.microsoft.com/en-us/download/dotnet/6.0
Solution 6:[6]
.NET 6.0 is coming with VS 2022 ,install the new visual studio version and proceed
Solution 7:[7]
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.
Solution 8:[8]
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 fromc:\Program Files (x86)\...
- Renamed the 32 versions folder, and all solved.
Solution 9:[9]
You must edit the file %PROGRAMFILES%\dotnet\sdk\[VERSION]\minimumMSBuildVersion with version of msbuild supported by VS 2019.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Drew Noakes |
Solution 2 | |
Solution 3 | |
Solution 4 | Ehsan |
Solution 5 | Hgrbz |
Solution 6 | Chathu.Thanthrige |
Solution 7 | Thomas Glaser |
Solution 8 | g.pickardou |
Solution 9 | user19140189 |