本文介绍了覆盖MSBuild中的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MSBuild命令行参考

In MSBuild Command-Line Reference

https://msdn.microsoft.com/zh-cn/library/ms164311.aspx

据说

/p:name =值

可用于覆盖项目级别的属性.在该页面上有一个示例

could be used to overwrite project level properties. And there's an example on that page

/property:WarningLevel = 2; OutDir = bin \ Debug

WarningLevel部分似乎不起作用,因为WarningLevel 不属于< PropertyGroup>默认情况下.

Which seems not working for WarningLevel part, as WarningLevel  belongs not to a <PropertyGroup> by default.

这是我在win32控制台项目中发现的:

This is what I found in a win32 console project:

  < ItemDefinitionGroup Condition =''''$(配置)| $(平台)'=='Debug | Win32'''>
    < ClCompile>
      < PrecompiledHeader>使用</PrecompiledHeader>
      < WarningLevel> Level3</WarningLevel>

  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <PrecompiledHeader>Use</PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>

...

我尝试过

<警告级别> $(WL)</警告级别>

<WarningLevel>$(WL)</WarningLevel>

并将WL设置为

并且警告级别可以通过WL覆盖.

And WarningLevel is overridable  through WL.

我的问题是:

是否有更简便的方法来覆盖ItemDefinitionGroup中的条目?

Is there a easier way to overwrite entries in ItemDefinitionGroup?

使用MSBuild进行构建时,是否有任何特殊原因不应该从命令行覆盖诸如WarningLevel(尤其是RuntimeLibrary)之类的条目?

Is there any particular reason that entries like WarningLevel (especially RuntimeLibrary) should not be overwritten from command line when building with MSBuild?

谢谢

源兴

推荐答案

您是说警告级别默认情况下不支持被覆盖吗?

Do you mean the WarningLeveldoes not support to be overwrite by default?

嗯,这似乎不适用于WarningLevelpart" ,我不确定您在这里的意思.像这样设置时,您是否有任何错误:

Hmmm, "Which seems not working for WarningLevelpart" , I'm not so sure what you mean here. Do you have any error when just set like this:

/property:WarningLevel=2;OutDir=bin\Debug 

我正试图了解此问题,并希望创建一些演示来重现它.但是我现在不太确定你的情况.

I'm trying to understand this issue and want to create some demos to reproduce it. But I'm not so sure of your scenario right now.

最诚挚的问候,


这篇关于覆盖MSBuild中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 14:10