Getting compilation error MSB3971 on Visual Studio Enterprise 2022

Shareef, Ruman 5 Reputation points
2023-06-14T06:35:40.3666667+00:00

I recently installed Visual Studio 2022 on a machine which had VS 2019.

When I create a project targeting .net6.0 I get the following error.

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. Update Visual Studio and/or your .NET SDK. Test C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 1229

I have verified I have all the necessary SDKs including for version 6.0. Both the SDK as well as the VS 2022 are 64 bit installations. The Path environment variable has C:\Program Files\dotnet which has the necessary SDK.

The .csproj target framework is also rightly set. I have repaired the installation, uninstalled and reinstalled it and have also removed VS 2019, but to no avail.

Kindly help.

Attached is a detailed log from the build output for further troubleshooting.BuildLog_Detailed.txt

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,449 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Shareef, Ruman 5 Reputation points
    2023-06-19T05:01:26.9533333+00:00

    The issue was with GLobal.JSON pointing to .net 3.1.

    Removed it and the issue resolved.

    1 person found this answer helpful.
    0 comments No comments

  2. Tianyu Sun-MSFT 34,431 Reputation points Microsoft External Staff
    2023-06-14T09:07:37.43+00:00

    Hello @Shareef, Ruman,

    Welcome to Microsoft Q&A forum.

    Is there any unnecessary Path environment variable set about dotnet/SDKs on your side, except C:\Program Files\dotnet? If so, please try to delete it/them and restart VS.

    Please open VS Installer > Modify > Individual components > .NET > and make sure that .NET 6.0 Runtime and .NET SDK have been checked > close VS and VS Installer > run devenv /ResetSettings in Developer Command Prompt for Visual Studio 2022 Enterprise > create a new project and check if the issue disappears.

    I may also suggest you try to install the latest version of .NET 6.0 separately. Disable any installed third-party extensions/antivirus temporarily, reboot your machine and check again.

    Sincerely,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.