Search code examples
visual-studiomsbuildwindows-runtimevisual-studio-2019c++-winrt

How can I specify "Target Platform Version" and "Target Platform Min. Version" when compiling with MSBuild, VS 2019, Platform Toolset v142


Project files have these settings in a PropertyGroup named Globals:

<PropertyGroup Label="Globals">
  ...
  <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
  <WindowsTargetPlatformMinVersion>10.0.14393.0</WindowsTargetPlatformMinVersion>
  ...
</PropertyGroup>

I wasn't able to find any documentation about how to set these on the command line with MSBuild.


Solution

  • Using the simple /p argument can do the trick. Using command like:

    msbuild xx.csproj/xx.sln /t:build /p:WindowsTargetPlatformVersion=xx;WindowsTargetPlatformMinVersion=xx (should be in one line) can specify the target version in runtime.

    Note: To run commands above, you should make sure the windows sdk version you wanna specify is installed in your machine.