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:
Change line 6 to:
<ReadLinesFromFile File="%(jsFilesToCombine.FullPath)">
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).
The ReadLinesFromFileTask
you are using to read the files takes a single file as input to the File
property (MSDN). You can't use this task to read lines from multiple files at once. You may however be able to use batching to run the task several times for each file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With