【问题标题】:How to override project properties on the command line using msbuild如何使用 msbuild 在命令行上覆盖项目属性
【发布时间】:2017-06-24 19:16:48
【问题描述】:

我正在尝试使用 msbuild 构建 Visual Studio 解决方案 (C++)

 msbuild.exe mysolution.sln /p:platform="ARM" /p:configuration="Release"

我收到了这个错误

error : all paths through this function will call itself [-Werror,-Winfinite-recursion]

我只想能够从命令行关闭 -Werror,而不是在 Project Properties > Configuration Properties > C/C++ > Treat Warnings As Errors 中关闭它

谢谢!

编辑 1。 我还想设置其他无法在代码中修复的项目属性,例如 Configuration Properties > General > Platform ToolsetConfiguration Properties > General > Use of STL。 FWIW,正如您从上面的命令行中看到的那样,我的目标是 ARM 平台。

【问题讨论】:

标签: android c++ visual-studio msbuild


【解决方案1】:

根据同样由 stijn 提供的this post,我们无法直接通过 MSBuild 命令行更改“TreatWarningAsError”的值。因为“TreatWarningAsError”是项目文件中的 ClCompile 而不是 PropertyGroup。 您可以通过 MSBuild 命令行添加目标调用 MSBuild 以将外部参数传递到项目文件中:

首先,更改项目文件中“TreatWarningAsError”的固定值:

<ClCompile>
   ...
   <TreatWarningAsError>$(TWAESettings)</TreatWarningAsError>
</ClCompile>

其次,在项目文件中添加一个目标:

  <Target Name="TestBuild" Returns="@(ManagedTargetPath)">
    <MSBuild Projects="YourProjectName.vcxproj" Targets="NormalBuild" Properties="TWAESettings=true"/>
  </Target>

第三,使用属性为真或假的MSBuild命令行:

msbuild /p:TWAESettings=false Or msbuild /p:TWAESettings=true

更新:

对于配置属性>常规>平台工具集和配置属性>常规>使用STL

您可以直接通过 MSBuild 命令行更改平台工具集:

msbuild /p:PlatformToolset=v140_xp

但我找不到“使用 STL”,而是找到“使用 ATL”。如果“Use of STL”是项目文件中的PropertyGroup,也可以直接通过MSBuild命令行进行更改。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-02
    • 1970-01-01
    • 2019-01-07
    • 1970-01-01
    相关资源
    最近更新 更多