Invalid static method invocation syntax: "[MSBuild]::IsRunningFromVisualStudio()"
Solution 1
1. Close all running instances of Visual Studio 2017
2. Launch (as Administrator) "Developer Command Prompt for VS 2017"
3. Type the following commands (replace Professional with your edition, either Enterprise or Community, or adjust the path accordingly):
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Framework.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Engine.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Conversion.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Tasks.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Utilities.Core.dll"
4. Restart Visual Studio 2017
Solution 2
It seems from the responses to this issue on github that it is often caused by having an older version of MSBuild in the GAC. This will then be used in preference to the bundled version that ships with the updated version of VS.
The solution is to remove the old version of Microsoft.Build from the gac.
-
Find the gac'd versions:
gacutil /l | findstr Microsoft.Build
-
Look for any of version 15.x.x.x and then remove them:
gacutil /u "Microsoft.Build, Version=15.{version_found}"
Restart Visual Studio
It may also be necessary to remove the related assemblies Microsoft.Build.Utilities.Core
, Microsoft.Build.Framework
and Microsoft.Build.Tasks.Core
of that version.
Related videos on Youtube
mortenma71
Updated on September 14, 2022Comments
-
mortenma71 over 1 year
After upgrading to Visual Studio 2017 15.5 none of my project will load correctly. All are marked unavailable.
I'm getting the following error for every project:
error : Invalid static method invocation syntax: "[MSBuild]::IsRunningFromVisualStudio()". Method '[MSBuild]::IsRunningFromVisualStudio' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(
a
,b
)). C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targetsReloading project produces this error prompt:
Adding new projects produce this error prompt:
-
Tahir Hassan about 6 yearsNot for me either.
-
Ondřej Kunc about 6 yearsI ran this commands on my build server and it broke all our builds - specifically it broke
vswhere.exe
utility, which locates concrete version of MSBuild. Had to fix it by locating all newly added assemblies by gcutil and unistall them usinggacutil /u
-
Nick Baker over 5 yearsFixed it for me as well. I had to run this as well:
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\System.Collections.Immutable.dll"
as I gotCould not load file or assembly 'System.Collections.Immutable blah blah
. -
orellabac over 5 yearsmmm this partially helped. I god rid of this problem but then I got to The
SDK Microsoft.NET.Sdk specified could not be found
-
orellabac over 5 yearsAfter that I had to install
Microsoft.CodeAnalysis.Workspaces.MSBuild
and alsoMicrosoft.Build.Locator
as recommended in stackoverflow.com/questions/49816884/… -
Rahul Reddy Vemireddy over 4 yearsThis has messed up my Visual Studio. Could you please suggest how to fix it?
-
Yuriy Oleynik over 4 years@RahulReddyVemireddy run all commands with flag
/u
(ex.gacutil /u
) -
alamoot over 3 yearsFixed my issue.