【发布时间】:2012-10-18 06:00:06
【问题描述】:
目前,我在MSBuild proj 文件中找到了他的以下代码。这真的很简单。定义 4 个 变量 并为每个变量调用一次我的 MSBuild 任务:
请代码~~
<ItemGroup><JS_File1 Include="file1.js"/></ItemGroup>
<ItemGroup><JS_File1 Include="file2.js"/></ItemGroup>
<ItemGroup><JS_File1 Include="file3.js"/></ItemGroup>
<ItemGroup><JS_File1 Include="file4.js"/></ItemGroup>
<JavaScriptCompressorTask SourceFiles="@(JS_File1)" OutputFile="@(JS_File1).min"/>
<JavaScriptCompressorTask SourceFiles="@(JS_File2)" OutputFile="@(JS_File2).min"/>
<JavaScriptCompressorTask SourceFiles="@(JS_File3)" OutputFile="@(JS_File3).min"/>
<JavaScriptCompressorTask SourceFiles="@(JS_File4)" OutputFile="@(JS_File4).min"/>
没有什么令人兴奋的。
我想知道这是否可以重构为这样的东西。
失败伪代码~~
<ItemGroup>
<JS_File1 Include="file1.js"/>
<JS_File1 Include="file2.js"/>
<JS_File1 Include="file3.js"/>
<JS_File1 Include="file4.js"/>
</ItemGroup>
<!-- now this is the shiz i have no idea about -->
foreach(@(JS_Files))
<JavaScriptCompressorTask SourceFiles="@(theFile)" OutputFile="@(theFile).min"/>
在 MSBuild 中是否可以这样做?
所以该任务被称为“每个文件一次”.. 还是更确切地说,“项目组中的每个项目一次”?
【问题讨论】:
标签: loops msbuild refactoring iteration