I’m trying to combine all javascript files in a project during the build process, but it just isn’t working for me. Here’s what I have:
<Target Name="CombineJS">
<CreateItem Include=".\**\*.js">
<Output TaskParameter="Include" ItemName="jsFilesToCombine" />
</CreateItem>
<ReadLinesFromFile File="@(jsFilesToCombine)">
<Output TaskParameter="Lines" ItemName="jsLines" />
</ReadLinesFromFile>
<WriteLinesToFile File="all.js" Lines="@(jsLines)" Overwrite="true" />
</Target>
MSBuild is throwing an error on the ReadLinesFromFile line saying there’s an invalid value for the “File” parameter. (No error when there’s only one file to combine)
So, two questions:
- What am I doing wrong?
- Is there a better way to combine files within an MSBuild task? I ask this question because I know that my current process removes all tabs and blank lines, which for me isn’t that big of a deal, but still kind of annoying.
Change line 6 to:
The
@operator is used when the input is ItemGroup which is essentially a semicolon-delimited list of strings.The
%operator is for expanding ItemGroups into strings (properties).