我有一个 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>
元素在这里做的事情 - 它将创建一个以 PropertyName 属性中的值命名的属性,并将设置value该属性的值为 Id 的值output来自 BuildStep 任务。您对 Id 的值没有影响 - 您只需将其存储在属性中以供以后参考,以便设置构建步骤的状态
考虑到这一点,我不明白为什么您担心创建的属性的名称将包含扩展的串联。只要属性名称是唯一的,您就可以在后续的 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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)