【问题标题】:How can I specify "Target Platform Version" and "Target Platform Min. Version" when compiling with MSBuild, VS 2019, Platform Toolset v142使用 MSBuild、VS 2019、Platform Toolset v142 编译时如何指定“目标平台版本”和“目标平台最低版本”
【发布时间】:2019-10-19 08:08:15
【问题描述】:

项目文件在名为 Globals 的 PropertyGroup 中有这些设置:

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

我找不到任何有关如何使用 MSBuild 在命令行上设置这些的文档。

【问题讨论】:

  • 标准命令行功能对这些不起作用吗? docs.microsoft.com/en-us/visualstudio/msbuild/…
  • 如果你对msbuild不熟悉,命令格式见:msbuild xx.csproj/xx.sln /t:build /p:WindowsTargetPlatformVersion=xx;WindowsTargetPlatformMinVersion=xx... 更多细节请参考stijn评论中的文档.
  • @LanceLi-MSFT 我不知道我可以使用 /p 参数简单地“按原样”提供项目文件中的值。请添加您的评论作为答案,我会接受。

标签: visual-studio msbuild windows-runtime visual-studio-2019 c++-winrt


【解决方案1】:

使用简单的/p 参数可以解决问题。使用如下命令:

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

注意:要运行上述命令,您应该确保您的机器上安装了您要指定的 windows sdk 版本。

【讨论】:

    猜你喜欢
    • 2020-07-17
    • 2018-01-23
    • 1970-01-01
    • 2017-01-30
    • 2018-10-19
    • 1970-01-01
    • 2016-07-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多