我想创建一个包含任意字符串/名称的“ItemGroup”,以便使用MSBuild转换,例如:
<ItemGroup> <Categories>First</Categories> <Categories>Second</Categories> </ItemGroup>
然后我希望将这些类别的转换传递到控制台应用程序中,例如:
/c @(Categories, ' /c ')
我之所以在引号中说“ItemGroup”,是因为我不确定以这种方式使用ItemGroups是否适用——因为我在文档中看不到ItemGroups 必须 但是,由于缺少强制的“Include”属性,使用上述命令会导致错误消息。
您可以在中使用任意字符串和文件 Item ,但必须使用以下语法:
Item
<ItemGroup> <Categories Include="First"/> <Categories Include="Second"/> </ItemGroup>
当你使用 使用任意字符串是指某些元数据将毫无意义。( %(Categories.FullPath) (例如)
%(Categories.FullPath)
<Target Name="ExecCommand"> <Exec Command="YourProgram.exe /c @(Categories, ' /c ')"/> <!-- Using transformation --> <Exec Command="YourProgram.exe @(Categories -> '/c %(Identity)')"/> </Target>