开发者

Conditional PropertyGroup in TFSBuild.proj

I am trying to set a PropertyGroup depending on the value of another PropertyGroup:

<PropertyGroup Condition="'$(BuildDefinitionName)'=='Dev1'">
    <DeploymentServer>DEVSERVER</DeploymentServer>
</PropertyGroup>

<PropertyGroup Condition="'$(BuildDefinitionName)'=='Main'">
    <DeploymentServer>MAINSERVER</DeploymentServer>
</PropertyGroup>

<PropertyGroup Condition="'$(BuildDefinitionName)'=='Release'">
    <DeploymentServer>RELEASESERVE开发者_StackOverflow中文版R</DeploymentServer>
</PropertyGroup>

Later on I have this target

<Target Name="AfterEndToEndIteration" Condition="'$(DeploymentServer)'!=''">
</Target>

This target is not being executed because $(DeploymentServer evaluates to ''. However, if I set the property unconditionally:

<PropertyGroup>
    <DeploymentServer>SCHVMOMNET3</DeploymentServer>
</PropertyGroup>

it works--the target gets executed.

The $(BuildDefinitionName) property is OK because I use it elsewhere as the name of a .testconfig file.

How do I get my target to execute based on a conditionally defined property?


I got this working by putting the PropertyGroup inside my target:

<Target Name="AfterEndToEndIteration">
    <PropertyGroup>
        <DeploymentServer Condition="'$(BuildDefinitionName)'=='Dev'">DEVSERVER</DeploymentServer>
        <DeploymentServer Condition="'$(BuildDefinitionName)'=='Main'">MAINSERVER</DeploymentServer>
        <DeploymentServer Condition="'$(BuildDefinitionName)'=='Release'">RELEASESERVER</DeploymentServer>
    </PropertyGroup>
</Target> 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜