开发者

test if an MSBuild property is defined?

In MsBuil开发者_如何学Pythond, is it possible to create an MSBuild condition (or another situation) that will evaluate whether a Property is 'defined' (presuming that this is previous to assigning the property a value somewhere)?

The following seems a little too clumsy to be reliable:

<PropertyGroup Label="Undefined State">
     <Defined></Defined>
</PropertyGroup>

<Choose>
   <When Condition="('$(Defined)' == '' OR '$(Defined)' != '')">
        <Message Text="Defined is probably/likely/assuredly defined"/>
    </When>
    <Otherwise>
       <Message Text="Defined is reportedly/maybe/possibly not defined"/>
    </Otherwise>
<Choose>


There exists common method for overriding properties.

Sample from C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets

   <PropertyGroup>
       <TargetFrameworkIdentifier Condition="'$(TargetFrameworkIdentifier)' == ''">.NETFramework</TargetFrameworkIdentifier>
       <TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' ">v4.0</TargetFrameworkVersion>
   </PropertyGroup>

If you will try to get value from $(NeverDefinedProperty) you just get an empty string. Can you describe the problem you want to solve?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜