开发者

Conditional PropertyGroup in TFSBuild.proj

开发者 https://www.devze.com 2023-01-03 11:16 出处:网络
I am trying to set a PropertyGroup depending on the value of another PropertyGroup: <PropertyGroup Condition=\"\'$(BuildDefinitionName)\'==\'Dev1\'\">

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

精彩评论

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

关注公众号