Visual Studio 2019 unable to load one project due to msbuild version

Andy Reynolds 25 Reputation points
2023-05-17T17:07:11.2166667+00:00

I'm setting up Visual Studio 2019 on a new Windows 11 PC and VS is unable to load one of the projects in a C# solution. Most of the projects in this solution target .NET Framework 4.5.2, but there is one targeting .NET Core 3.1, and VS won't load the 3.1 project with the following error:

error  : The project file cannot be opened. Version 7.0.302 of the .NET SDK requires at least version 17.4.0 of MSBuild. The current available version of MSBuild is 16.11.2.50704. Change the .NET SDK specified in global.json to an older version that requires the MSBuild version currently available.

I've also got VS 2022 installed on the PC for other newer applications.

I'm able to open the project without a problem on a Win 10 PC with both VS 2019 and 2022 installed.

I've searched for global.json, but it doesn't exist. I've also tried uninstalling and reinstalling both VS 2019 and 2022, and installing the SDK for .NET Framework 4.8, .NET Core 3.1, and .NET 7.0.

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

2 answers

Sort by: Most helpful
  1. Periam, David 50 Reputation points
    2023-07-19T11:06:50.82+00:00

    I resolved this following these three steps:

    1. install of .Net Framework 3.1
      1. AspNetCore-Runtime-3.1.32-win-x64;
      2. dotnet-runtime-3.1.32-win-z64;
      3. dotnet-sdk-3.1.426-win-x64;
    2. rename of "minimumMSBuildVersion" file, in "c:\program files\dotnet\sdk\7.0.306 to "___minimumMSBuildVersion"
    3. Restart Visual Studio IDE Problem solved.
    10 people found this answer helpful.

  2. Konstantinos Passadis 17,456 Reputation points MVP
    2023-05-17T17:21:42.3933333+00:00

    Hello

    Can you try to set explicitly the version

    https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2022

    https://learn.microsoft.com/en-us/visualstudio/msbuild/find-and-use-msbuild-versions?view=vs-2022

    https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version#configure-multiple-projects?WT.mc_id=DT-MVP-5003386

    If your source directory contains multiple project and you would like to set the language version for all projects explicitly, you can create Directory.Build.props file that contains the <LangVersion> element.

    <Project>

    <PropertyGroup>

    <LangVersion>preview</LangVersion>

    </PropertyGroup>

    </Project>

    Create a Directory.Build.props

    <Project>

    <PropertyGroup>

    **<MSBuildToolsVersion>17.0</MSBuildToolsVersion>**
    

    </PropertyGroup>

    </Project>

    This will force your project to use MSBuild version 17.0.

    I hope this helps!

    Kindly mark the answer as Accepted and Upvote in case it helped!

    Regards