当使用MSBuild、VS 2019和Platform Toolset v142进行编译时,我该如何指定“目标平台版本”和“目标平台最小版本”?

3

项目文件中有一个名为Globals的PropertyGroup,其中包含以下设置:

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

我没有找到任何有关如何在MSBuild命令行中设置这些内容的文档。


标准命令行功能对这些不起作用吗?https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-properties?view=vs-2019#global-properties - stijn
如果您不熟悉msbuild,命令的格式如下:msbuild xx.csproj/xx.sln /t:build /p:WindowsTargetPlatformVersion=xx;WindowsTargetPlatformMinVersion=xx... 更多细节请参考stijn评论中的文档。 - LoLance
@LanceLi-MSFT 我不知道我可以使用/p参数直接从项目文件中提供值。请将您的评论添加为答案,我会接受它。 - Patrick
1个回答

4

使用简单的/p参数即可轻松实现。使用命令如下:

msbuild xx.csproj/xx.sln /t:build /p:WindowsTargetPlatformVersion=xx;WindowsTargetPlatformMinVersion=xx (应该在一行中)可以在运行时指定目标版本。

注意:要运行上述命令,您需要确保您想要指定的Windows SDK版本已经安装在您的机器上。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接