我正在尝试根据另一个PropertyGroup的值设置PropertyGroup:
<PropertyGroup Condition="'$(BuildDefinitionName)'=='Dev1'">
<DeploymentServer>DEVSERVER</DeploymentServer>
</PropertyGroup>
<PropertyGroup Condition="'$(BuildDefinitionName)'=='Main'">
<DeploymentServer>MAINSERVER</DeploymentServer>
</PropertyGroup>
<PropertyGroup Condition="'$(BuildDefinitionName)'=='Release'">
<DeploymentServer>RELEASESERVER</DeploymentServer>
</PropertyGroup>
后来我有了这个目标
<Target Name="AfterEndToEndIteration" Condition="'$(DeploymentServer)'!=''">
</Target>
此目标未执行,因为$(DeploymentServer计算为''。但是,如果我无条件地设置该属性:
<PropertyGroup>
<DeploymentServer>SCHVMOMNET3</DeploymentServer>
</PropertyGroup>
它有效 - 目标被执行。
$(BuildDefinitionName)属性没问题,因为我在别处使用它作为.testconfig文件的名称。
如何根据条件定义的属性来执行目标?
答案 0 :(得分:1)
我通过将PropertyGroup放在我的目标中来实现这个目的:
<Target Name="AfterEndToEndIteration">
<PropertyGroup>
<DeploymentServer Condition="'$(BuildDefinitionName)'=='Dev'">DEVSERVER</DeploymentServer>
<DeploymentServer Condition="'$(BuildDefinitionName)'=='Main'">MAINSERVER</DeploymentServer>
<DeploymentServer Condition="'$(BuildDefinitionName)'=='Release'">RELEASESERVER</DeploymentServer>
</PropertyGroup>
</Target>