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

1

3

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.

Nail answered 19/10, 2019 at 8:8 Comment(3)
Doesn't the standard commandline functionality work for these? learn.microsoft.com/en-us/visualstudio/msbuild/…Sloat
In case you're not familiar with msbuild, the format of the commands see: msbuild xx.csproj/xx.sln /t:build /p:WindowsTargetPlatformVersion=xx;WindowsTargetPlatformMinVersion=xx... More details please refer to the document in stijn's comment.Colene
@LanceLi-MSFT I wasn't aware I could provide the values from the project file simply "as is" using the /p argument. Please add your comment as an answer, and I'll accept it.Nail
C
4

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.

Colene answered 21/10, 2019 at 15:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.