I am trying to compile a C VS project from PowerShell using msbuild
. The command I'm using for now is:
msbuild .\my_solution.sln /t:Rebuild /p:Configuration=Release
But when I try to build I get the following error:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.props(31,5): error MSB4186: Invalid static method invocation syntax: "[Microsoft.Build.Utilities.ToolLocat
ionHelper]::FindRootFolderWhereAllFilesExist($(_VCTargetsPathFolders), $(_RelativeToolsetFiles))". Method 'Microsoft.Build.Utilities.ToolLocationHelper.FindRootFolderWhereAllFilesExist' not found. Static meth
od invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)).
I have already tried the following:
- Run as admin
- Repair Visual Studio
- Full uninstall and reinstall of Visual Studio.
Other useful info:
- I am using Visual Studio Community 2019.
- My
msbuild
path is:C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
- My
VCTargetsPath
is:C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\
- Worth noting that on the CLI command I haven't added the additional include directories nor the additional dependencies while in the UI version I have. Despite this, the error I am expecting is somewhat like
unknown reference to <function>
. I am trying to solve this first error before proceeding to link the required libraries, I don't believe this causes the problem but I'm mentioning it just in case.
The strange thing is that if I rebuild using the Visual Studio UI the project builds without any problem.
Despite this, I need to build from CLI so I would be really thankful if someone shares where the problem may be.