MSBUILD 批处理任务批量执行每个语句
我的 MSBuild 脚本中有以下任务:
<Target Name="ZipStates">
<Message Text="CREATING ZIP FOR %(StateSet.Name)" />
<CreateItem Include="$(StagingArea)\v$(VersionString)\States\%(StateSet.Name)\v$(VersionString)%20%(StateSet.Abbreviation)XTend\**\*.*" >
<Output ItemName="ZipFiles" TaskParameter="Include"/>
</CreateItem>
<MSBuild.Community.Tasks.Zip Files="@(ZipFiles)"
ZipFileName="$(StagingArea)\v$(VersionString)\States\%(StateSet.Name)\v$(VersionString)%(StateSet.Abbreviation).zip" />
</Target>
<ItemGroup>
<StateSet Include="AK">
<Name>Alaska</Name>
<Abbreviation>AK</Abbreviation>
</StateSet>
<StateSet Include="FL">
<Name>Florida</Name>
<Abbreviation>FL</Abbreviation>
</StateSet>
<StateSet Include="LA">
<Name>Louisiana</Name>
<Abbreviation>LA</Abbreviation>
</StateSet>
</ItemGroup>
输出如下所示:
ZipStates: 为阿拉斯加创建邮政编码 为佛罗里达创建邮政编码 为路易斯安那州创建邮政编码 创建 zip 文件“C:\StagingArea\v5_6_0\States\Alaska\v5_6_0AK.zip”。
看来,当我以这种方式执行批处理时,任务中的每个命令都会针对项目组批处理中的每个节点执行,然后继续下一步。 我最终得到的是 3 个 zip 文件,它们都包含相同的文件。
有人知道我可以如何以不同的方式做到这一点吗?
I have the following task in my MSBuild script:
<Target Name="ZipStates">
<Message Text="CREATING ZIP FOR %(StateSet.Name)" />
<CreateItem Include="$(StagingArea)\v$(VersionString)\States\%(StateSet.Name)\v$(VersionString)%20%(StateSet.Abbreviation)XTend\**\*.*" >
<Output ItemName="ZipFiles" TaskParameter="Include"/>
</CreateItem>
<MSBuild.Community.Tasks.Zip Files="@(ZipFiles)"
ZipFileName="$(StagingArea)\v$(VersionString)\States\%(StateSet.Name)\v$(VersionString)%(StateSet.Abbreviation).zip" />
</Target>
<ItemGroup>
<StateSet Include="AK">
<Name>Alaska</Name>
<Abbreviation>AK</Abbreviation>
</StateSet>
<StateSet Include="FL">
<Name>Florida</Name>
<Abbreviation>FL</Abbreviation>
</StateSet>
<StateSet Include="LA">
<Name>Louisiana</Name>
<Abbreviation>LA</Abbreviation>
</StateSet>
</ItemGroup>
The output looks like this:
ZipStates:
CREATING ZIP FOR Alaska
CREATING ZIP FOR Florida
CREATING ZIP FOR Louisiana
Creating zip file "C:\StagingArea\v5_6_0\States\Alaska\v5_6_0AK.zip".
It seems that when I do a batch in this way each command in the task is executed for every node in the item group batch and then it moves on to the next step. What I end up with is 3 zips that all contain the same files.
Anyone have an idea of how I can do this differently?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
弄清楚了。 我需要修改创建文件列表的方式,使每个列表都是唯一的。 就像这样:
Figured it out. I needed to modify the way I was creating the file list to be unique per list. Like so: