Working with dotnet8 projects in Visual Studio 2022

Recently Microsoft released .NET 8.0 RC. And when we try to load a .NET 8 Web API project in Visual Studio - we will get a message like this. - The current Visual Studio version does not support targeting .NET 8.0. Either target .NET 7.0 or lower, or use Visual Studio version 17.8 or higher.

Visual Studio 2022 - .NET 8 project

We can fix this issue by changing the Visual Studio configuration like this. Click on the Tools > Select options. And under Environment, select Preview Features. And in the right side select the Use previews of the .NET SDK (requires restart).

Visual Studio 2022 - options

Once it is selected, we need to restart the Visual Studio. Once it opened again, we will be able to load .NET 8.0 RC projects and we will also able to create new .NET 8.0 projects using VS 2022.

Here is an example Web API AOT project template which is part of .NET 8.0

Visual Studio 2022 - New Project

And we can also select the .NET 8.0 as Framework for new ASP.NET Core Web API project.

Visual Studio 2022 - New Project - Framework

This way we can configure .NET 8.0 SDK in Visual Studio 2022.

Happy Programming.