我有一个的ItemGroup,我使用其元数据作为在我MSBuild项目进行批量处理标识符。例如:

        <BuildStep
          TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
          BuildUri="$(BuildUri)"
          Name="RunUnitTestsStep-%(TestSuite.Filename)-%(TestSuite.Extension)"
          Message=" - Unit Tests: %(TestSuite.Filename): %(TestSuite.Extension)">

          <Output
            TaskParameter="Id"
            PropertyName="RunUnitTestsStepId-%(TestSuite.Filename)-%(TestSuite.Extension)" />
        </BuildStep>

但是,这是行不通的,因为在扩展,这是无效字符ID的点(在BuildStep任务)。因此,的MSBuild总是失败上BuildStep任务。

我一直在试图移除点,但没有运气。也许有办法的一些元数据添加到现有的连接的ItemGroup?理想情况下,我想有这样的事情%(TestSuite.ExtensionWithoutDot)。我怎样才能做到这一点?

有帮助吗?

解决方案

我觉得你稍微感到困惑什么<Output>元素在这里做什么 - 这将创建一个与该属性名的属性值命名的属性,将设置的的该属性是价值从BuildStep任务的Id 输出。您对ID的值没有影响 - 你只需将它保存在供以后参考属性,以设置生成步骤的状态

考虑到这一点,我不明白为什么你关心的是物业创建将有一个名称将包括扩展的连接。只要属性名称是独一无二的,你可以在以后引用它在随后的BuildStep任务,我相信你的测试包中的文件名就足以表明其唯一。

在事实上,可以避免不必创建用于跟踪每个测试包/ buildstep对独特的性质,如果你没有目标配料:

<Target Name="Build"
        Inputs="@(TestSuite)"
        Outputs="%(Identity).Dummy">
    <!--
    Note that even though it looks like we have the entire TestSuite itemgroup here,
    We will only have ONE - ie we will execute this target *foreach* item in the group
    See http://beaucrawford.net/post/MSBuild-Batching.aspx
    -->


    <BuildStep
          TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
          BuildUri="$(BuildUri)"
          Name="RunUnitTestsStep-%(TestSuite.Filename)-%(TestSuite.Extension)"
          Message=" - Unit Tests: %(TestSuite.Filename): %(TestSuite.Extension)">

          <Output
            TaskParameter="Id"
            PropertyName="TestStepId" />
        </BuildStep>

    <!--
    ..Do some stuff here..
    -->

    <BuildStep Condition=" Evaluate Success Condition Here "
           TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
           BuildUri="$(BuildUri)"
           Id="$(TestStepId)"
           Status="Succeeded" />
    <BuildStep Condition=" Evaluate Failed Condition Here "
           TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
           BuildUri="$(BuildUri)"
           Id="$(TestStepId)"
           Status="Failed" />
</Target>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top