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.
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).
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
And we can also select the .NET 8.0 as Framework for new ASP.NET Core Web API project.
This way we can configure .NET 8.0 SDK in Visual Studio 2022.