See the public documentation. The GAC is a folder where different installations of VS on the same machine look for assemblies that are commonly used. If an assembly is in the GAC, it will be prioritized over any other assembly.
The only MSBuild assemblies you may see in the GAC are version 4.8. There is no reason any modern (15.1+) MSBuild assembly should be in the GAC today.
Run the EnumerateMSBuild powershell script from our repo. It will output a msbuild_versions.txt
file that lists MSBuild assemblies in their common folders along with their versions.
- If on Visual Studio 16.8 or higher, repair your installation.
- Run these commands on a developer command prompt with admin privileges. Match the versions as necessary.
gacutil /u "MSBuild, Version=15.1.0.0" gacutil /u "Microsoft.Build.Conversion.Core, Version=15.1.0.0" gacutil /u "Microsoft.Build, Version=15.1.0.0" gacutil /u "Microsoft.Build.Engine, Version=15.1.0.0" gacutil /u "Microsoft.Build.Tasks.Core, Version=15.1.0.0" gacutil /u "Microsoft.Build.Utilities.Core, Version=15.1.0.0" gacutil /u "Microsoft.Build.Framework, Version=15.1.0.0" gacutil /u "Microsoft.NET.StringTools, Version=1.0.0.0" gacutil /u "BuildXL.Processes, Version=1.0.0.0" gacutil /u "BuildXL.Utilities.Core, Version=1.0.0.0" gacutil /u "BuildXL.Native, Version=1.0.0.0" gacutil /u "Microsoft.VisualStudio.SolutionPersistence, Version=1.0.0.0"
- If you want to do this 'safely', move the folder out of the GAC and return it if it doesn't resolve the issue.
We have an issue tracking other assemblies that can cause problems when in the GAC. If one of these assemblies is causing issues for you, refer to How to Remove MSBuild Assemblies from the GAC while changing the assembly name and version.