【问题标题】:Conditional PropertyGroup in TFSBuild.projTFSBuild.proj 中的条件属性组
【发布时间】:2010-06-16 10:43:47
【问题描述】:

我正在尝试根据另一个 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 文件的名称。

如何让我的目标根据条件定义的属性执行?

【问题讨论】:

    标签: .net msbuild tfsbuild


    【解决方案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> 
    

    【讨论】:

      猜你喜欢
      • 2017-06-07
      • 1970-01-01
      • 2018-12-31
      • 2019-08-16
      • 2019-12-19
      • 1970-01-01
      • 1970-01-01
      • 2020-01-17
      • 2011-01-02
      相关资源
      最近更新 更多