Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild - MSB4019 Due to invalid path (Visual Studio 2019)

I am getting below error, while building C++ solution on VS2019 via command prompt.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.ToolsetLocation.props(50,3): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160Platforms\Win32\Platform.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160Platforms\Win32\Platform.props" is correct, and that the file exists on disk.

After observing it is very clear that there is an issue with the path created internally at some props file. It is not very clear why and from where this is coming up.

Any pointers would be of great help.

Thanks in advance.

like image 538
Shailesh Avatar asked Oct 18 '25 14:10

Shailesh


1 Answers

This was not due to the installation issues. This was caused due to VCTargetsPath passed to the MSBuild.exe. In VS2017, it was expecting the VCTargetsPath to be passed in the build command whereas it failed with construction of invalid path if we pass the value in VS2019. Hence after removing the VCTargetsPath from the command all worked well for me.

like image 187
Shailesh Avatar answered Oct 21 '25 01:10

Shailesh