Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用MSBuild,如何通过迭代项组中的文件来构造动态字符串?_Msbuild_Msbuild Task - Fatal编程技术网

使用MSBuild,如何通过迭代项组中的文件来构造动态字符串?

使用MSBuild,如何通过迭代项组中的文件来构造动态字符串?,msbuild,msbuild-task,Msbuild,Msbuild Task,我需要创建多个/testcontainer:parameters,以便将其输入到exec的MsTest任务中 我有以下资料: <ItemGroup> <TestFiles Include="$(ProjectPath)\**\UnitTest.*.dll" /> </ItemGroup> 我正在尝试使用MSBuild的内部结构,而不必创建自定义任务,这可能吗 TIA试试这个: <Message Text="TestFiles= @(Te

我需要创建多个/testcontainer:parameters,以便将其输入到exec的MsTest任务中

我有以下资料:

  <ItemGroup>
    <TestFiles Include="$(ProjectPath)\**\UnitTest.*.dll" />
  </ItemGroup>
我正在尝试使用MSBuild的内部结构,而不必创建自定义任务,这可能吗

TIA试试这个:

<Message Text="TestFiles= @(TestFiles-> '&quot;%(Fullpath)&quot;', ' ')" />


参考资料:


这实际上取决于以后的使用情况。例如,您要将其发送到的任务,它是否在项目列表中接受,您希望调用它一次还是多次

如果要调用一次,则使用@(…)语法;如果要多次调用,则使用%(…)语法进行批处理

调用一次

<Message Text="Test Files: @(TestFiles->'/testcontainer:%(RecursiveDir)%(Filename)%(Extension)')"/>

多次调用

<Message Text="Test Files: /testcontainer:%(TestFiles.RecursiveDir)%(TestFiles.Filename)%(TestFiles.Extension)"/>


有关批处理的更多信息,请参见

我想为mstest构建参数:也就是说,如果您想执行mstest案例,那么您应该查看我的博客条目。
<Message Text="Test Files: /testcontainer:%(TestFiles.RecursiveDir)%(TestFiles.Filename)%(TestFiles.Extension)"/>