How do I prepend a prefix to Ant's srcfile marker within the apply task?
Given the f开发者_如何学Pythonollowing ant task:
<apply executable="${mstest}" addsourcefile="false">
<arg value="/resultsfile:TestResults.trx" />
<arg value="/testsettings:ReleaseCodeCoverage.testsettings" />
<arg value="/detail:errormessage" />
<srcfile />
<fileset dir="bin/${buildType}">
<patternset>
<include name="*Tests.dll" />
</patternset>
</fileset>
</apply>
How can I apply the prefix /TestContainer:
to the contents of <srcfile />
?
MSTest delimits switch names with a semicolon, not a space, so I can't just append it as <arg value="/TestContainer">
. I've also tried <srcfile prefix="/TestContainer:" />
as suggested here, but this is not supported in my version (1.7).
This is a bit of a cheat, but you might be able to adapt it to your case. The apply
task has a nested element targetfile
that can be used in the same way as srcfile
- placed between the command arguments where needed. The value of targetfile is derived from srcfile using a mapper element. So you can attach prefixes. Something like this perhaps:
<apply executable="${mstest}" addsourcefile="false" relative="true">
<arg value="/resultsfile:TestResults.trx" />
<arg value="/testsettings:ReleaseCodeCoverage.testsettings" />
<arg value="/detail:errormessage" />
<targetfile/>
<fileset dir="bin/${buildType}">
<patternset>
<include name="*Tests.dll" />
</patternset>
</fileset>
<mapper type="regexp" from="(.*)" to="/TestContainer:bin/${buildType}/\1" />
</apply>
Note the use of the relative
attribute, otherwise the path gets prefixed in front of the target 'filename'.
精彩评论