43

I have installed .NET 6.0 SDK and Visual Studio 2022. However, Visual Studio 2022 does not offer the ability to select .NET 6.0.

I know I can edit the project file with the target framework so please don't suggest that. This question is specifically around the Visual Studio 2022 UI.

dotnet sdks

Visual Studio 2022 UI

Edit 1:

.NET 6.0 Runtime has been selected in the Visual Studio Installer for Visual Studio 2022

Visual Studio Installer

Edit 2:

I can create .NET 6.0 projects but cannot seem to target .NET 6.0 in existing projects which were previously .NET 5.0.

New Project

2
  • 5
    Any update on this? The same thing has happened to me. I installed VS 2022, .Net 6.0 Runtime was/is selected, .Net SDK was/is selected. I even went to the .Net download site and downloaded the SDK and installed it. Yet .Net 6 does not show up in the Target Framework dropdown and when I manually converted a project VS tells me that .Net 6 is not supported. My current guess is that it has something to do with a global.json file somewhere but I've gotta figure out where. Nov 12, 2021 at 20:07
  • 2
    Strangely, .Net 6 does show up in the new project dialog. I was able to create a new ASP.Net project using 6.0. In that new project .Net 6 is listed in the target framework dropdown and the project will build. Switch back to an existing ASP.Net project and .Net 6.0 is no longer in the target framework dropdown. Nov 12, 2021 at 20:18

6 Answers 6

21

If your solution has a gobal.json file, you can either delete it or update the sdk version over there to the latest. At the point of this answer the latest .NET version is 6.0.0 with the sdk version as 6.0.100 (Latest sdk version could be found at the dotnet core site where you downloaded your sdk)

{
    "sdk": {
        "version": "6.0.100"
    }
}

Where to confirm your sdk version from your download

After you have done that, 'Unload' and 'Reload' your project and the latest .Net Core target should show up in the dropdown.

3
  • 3
    This was also the solution in my case. Remember that the global.json does not have to be placed in the same directory as the .csproj file, but may also be in a higher directory (in my case on the level of the .sln file), so I did not see it at first glance.
    – Andi
    Nov 23, 2021 at 11:10
  • 2
    This was answer. We had a global.json file which was targeted to .NET 5. This was done so our build agents used the correct SDK when doing automated builds. Updating this to 6.0.100 allows .NET 6.0 to be selected in the VS2022 now. Thank you very much @Anup! Solid answer.
    – Oliver
    Nov 23, 2021 at 11:49
  • 1
    It doesn't help me
    – Win4ster
    Feb 21, 2022 at 15:39
10

I wonder if this is the same problem I've been struggling with - you can't change an existing project that is not in the 'sdk' format to net 6. But there is an upgrade assistant that will convert it for you.
See https://learn.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-winforms-framework

You have to install the upgrade assistant with

dotnet tool install -g upgrade-assistant

After installation, you can either analyze your project

cd "C:\your solution path"
upgrade-assistant analyze yourProject.csproj

or run the upgrade by

cd "C:\your solution path"
upgrade-assistant upgrade yourProject.csproj

The assistant will guide you through the steps.

6
  • 1
    That is good for upgrading an existing project. Afterwards you have the upgrade-assistant CLI available in the console. However, in my case, it didn't help, since the assistant didn't run through without issues.
    – Matt
    Jan 5, 2022 at 13:42
  • Update: It took me some time, but I managed to upgrade an old WinForms project by using the upgrade-assistant - it is important to understand that it runs you through a couple of steps (like a workflow) and you need to review each step. If you're done with it, you can proceed by pressing "1" to start the next step - until the workflow completed. This way I could make it work and the project now runs with .NET 6. The CLI line is just for installing the assistant, after installation run upgrade-assistant /? to see the available options. You have to specify a project or solution.
    – Matt
    Jan 28, 2022 at 10:01
  • 1
    I tried to upgrade a .NET Framework 4.6.1 with the upgrade-assistant tool. The tool upgraded the project to netstandard20. Did you experience the same issue? Apr 12, 2022 at 2:46
  • @wonderfulworld , for me also same case it upgraded to netstandard20 and post that i am not able to change the target framework. Did you found the solution? Jun 30, 2022 at 10:14
  • when we use the upgrade-assistant tool it creates two projects one with the backup and other the normal one. in my case normal one has netstandard20 , where as the back up is pointing to the net60 Jul 1, 2022 at 7:11
8

During Visual Studio setup, you need to select the ".NET 6.0 Runtime". As can be seen in the screenshot, this option not only includes the runtime itself but also "templates for developing [...] .NET 6.0 applications".

screenshot

You can modify your installation by starting "Apps & Features" from the Windows start menu or by selecting Tools/"Get Tools and Features..." from the Visual Studio menu bar.

10
  • 3
    Thank you, this value is set in the Visual Studio Installer already.
    – Oliver
    Nov 11, 2021 at 13:36
  • @Oliver: Hm, strange. Can you create a new .NET 6 project in Visual Studio?
    – Heinzi
    Nov 11, 2021 at 13:47
  • 1
    @Oliver: Strange. Can you create a new .NET 6 project in VS 2022?
    – Heinzi
    Nov 23, 2021 at 8:22
  • 3
    I can create .NET 6.0 projects, but it seems I cannot change the Target Framework from .NET 5.0 -> .NET 6.0
    – Oliver
    Nov 23, 2021 at 8:31
  • 2
    On a new PC, I have Installed VS Enterprise LTS 2022. I selected .NET 5 and .NET 6 runtimes in the installer. Also I installed .NET SDKs 3.1, 5.0, 6.0 for x64. Still I cannot see .NET 5 and .NET 6. What am I missing?
    – Matt
    Jan 5, 2022 at 12:58
2

I have faced this issue when i used upgrade-assistant. it got upgraded to netstandard20. as part of the migration it has created the back up project also. when i open the back up project it was pointing to the net60.

Apart you can open the project file and target to the net6.0. try to unload and reload the project if it is not reflecting immediately.

1

If none of the other answers work, double check you didn't open up the project in an old version of Visual Studio. I have VS 2022 installed but the default when double clicking a .sln file was still VS 2019. I only had .NET 6 installed for 2022.

1
  • Yes, and if you have a parallel installation there is a "Visual Studio Version Selector" APP installed from Microsoft where you can choose which version to use when opening SLN files. If you select the old version then VS remembers it and opens the old version of VS every time - causing trouble like here.
    – Matt
    Feb 15 at 6:53
0

I install VS 2022 and cannot create any .NET 6 applications. I am trying to create a C# .NET 6 console application but VS only allows / shows .NET framework version up to 4.8.

I can edit and build a .NET 6 solution that someone else created but I cannot create one myself with my VS 2022 v17.2.6.

1
  • 2
    So it turns out I CAN create a .NET 6 console application. I was using the "Console App (.NET Framework)" where I should have used the "Console App" option. Jul 17, 2022 at 13:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.