Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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_Itemgroup - Fatal编程技术网

在MSBuild中创建字符串的项组

在MSBuild中创建字符串的项组,msbuild,itemgroup,Msbuild,Itemgroup,我想创建一个包含任意字符串/名称的“ItemGroup”,以便使用MSBuild转换,例如: <ItemGroup> <Categories>First</Categories> <Categories>Second</Categories> </ItemGroup> 我之所以在引号中说“ItemGroup”,是因为我不确定这样使用ItemGroups是否适用——因为我在文档中看不到任何内容说明ItemGr

我想创建一个包含任意字符串/名称的“ItemGroup”,以便使用MSBuild转换,例如:

<ItemGroup>
    <Categories>First</Categories>
    <Categories>Second</Categories>
</ItemGroup>
我之所以在引号中说“ItemGroup”,是因为我不确定这样使用ItemGroups是否适用——因为我在文档中看不到任何内容说明ItemGroups必须是文件,但是使用上述内容会导致错误消息,因为缺少必需的“Include”属性

  • 有没有一种方法可以使用ItemGroups执行上述操作
  • 或者,有没有更好的方法来实现上述目标而不使用项目组

您可以使用任意字符串以及
项中的文件,但必须使用以下语法:

<ItemGroup>
  <Categories Include="First"/>
  <Categories Include="Second"/>
</ItemGroup>

您可以使用任意字符串以及
项中的文件,但必须使用以下语法:

<ItemGroup>
  <Categories Include="First"/>
  <Categories Include="Second"/>
</ItemGroup>

+1,但注意-@(Categories,“/c”)表示“/c”将是项目之间的分隔符,因此您的最后一个项目将缺少/c(或第一个项目,具体取决于您的POV)。你真的需要这样的转换:@(Categories->'/c%(Identity)')来在你所有的物品前面获得/c是的,你是对的,但这就是为什么他使用“/c@(Categories,/c')”+1,但是注意-@(Categories,/c')意味着“/c”将是物品之间的分隔符,因此你的最后一个物品将丢失/c(或者第一个,取决于你的POV). 你真的需要这样的转换:@(Categories->'/c%(Identity)')才能在你所有的项目前面得到/c是的,但这就是他使用'/c@(Categories,/c')的原因
<Target Name="ExecCommand">
  <Exec Command="YourProgram.exe /c @(Categories, ' /c ')"/>

  <!-- Using transformation -->
  <Exec Command="YourProgram.exe @(Categories -> '/c %(Identity)')"/>
</Target>