Unable to compile .net 6.0 projects in VS 2022

Datta Kulkarni 21 Reputation points Microsoft Employee
2023-01-03T15:52:56.48+00:00

I am unable to compile .net 6.0 projects in VS 2022 (version 17.4.3). I see error message that - MSB3971 The reference assemblies for ".NETFramework,Version=v6.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher.

I installed and checked that .net6 exists as you can see below the output of dotnet --list-sdk. Also checked that there is no global.json file anywhere in the system. Since I was unable to build project which was already converted to net6.0, I created a new console project in VS 2022 and ran into same error. While creating new project I got the option to select .net 6.0 but once created I started getting the same MSB3971 error.

dotnet --list-sdks
3. 1.300 [C:\Users\dkulkarn\AppData\Local\Microsoft\dotnet\sdk]
3. 1.426 [C:\Program Files\dotnet\sdk]
3. 1.426 [C:\Program Files\dotnet\sdk]
5. 0.415 [C:\Program Files\dotnet\sdk]
5. 0.415 [C:\Program Files\dotnet\sdk]
6. 0.112 [C:\Program Files\dotnet\sdk]
6. 0.112 [C:\Program Files\dotnet\sdk]
6. 0.307 [C:\Program Files\dotnet\sdk]
6. 0.307 [C:\Program Files\dotnet\sdk]
7. 0.101 [C:\Program Files\dotnet\sdk]
7. 0.101 [C:\Program Files\dotnet\sdk]

I also noticed that .net 6 is not present in target framework list which is shown within project properties.

.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
337 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,741 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 54,901 Reputation points
    2023-01-03T16:11:34.96+00:00

    Firstly, there is a known issue where the RTM release of the .NET 7 SDK which ships with VS 2022 can stomp the .NET 6 SDK. You can refer to some help here but ultimately repairing the .NET 6 SDK seems to resolve it IIRC.

    The second thing is that VS 2022 is x64 whereas previous versions of VS where x86. The SDKs are installed as both x86 and x64. The version of MSBuild running in VS 2022 is x64 so you need to ensure you have the x64 version of the SDK installed as well.

    Your post seems to have conflicting reports of the .NET 6 availability.

    While creating new project I got the option to select .net 6.0
    I also noticed that .net 6 is not present in target framework list which is shown within project properties

    So I'm confused here. When you create a new project you should see the options of .NET 6 and .NET 7. However be aware not every project type supports both frameworks. If you open an existing .NET Core/5/6/7 project then you should see the option for .NET 6. However you will not see this option for .NET Framework projects as they only go up to .NET 4.8. To convert a .NET Framework app to .NET 6 you'll need to convert the project to the SDK project format first and then you can set the target framework. The UI (outside a helper extension) doesn't support this.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.