I'm trying to build my Visual Studio solution with MSBuild and I'm using this command to do so:
msbuild mysolution.sln /p:Configuration=Debug /p:PlatformToolset=v142
But I get this following error:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0.19041.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [D:...\mysolution.vcxproj]
Even though I have it installed in Visual Studio Installer and Visual Studio can use it without an issue:

Using the vcvarsall.bat before the msbuild fixed it.
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 10.0.19041.0
I think you might also need to do that before the msbuild:
set UseEnv=true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With