MSBuild / YUICompressor error
Using the following msbuild config:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
<UsingTask
TaskName="CompressorTask"
AssemblyFile="Yahoo.Yui.Compressor.dll" />
<PropertyGroup>
<JavaScriptOutputFile Condition=" '$(JavaScriptOutputFile)'=='' ">..\..\site.se\javascript\javascript.min.js</JavaScriptOutputFile>
</PropertyGroup>
<Target Name="CompressorTask">
<ItemGroup>
<JavaScriptFiles Include="..\..\site.se\javascript\javascript.js"/>
</ItemGroup>
<CompressorTask
JavaScriptFiles="@(JavaScriptFiles)"
ObfuscateJavaScript="True"
PreserveAllSemicolons="True"
DisableOptimizations="False"
EncodingType="utf-8"
DeleteJavaScriptFiles="false"
LineBreakPosition="-1"
JavaScriptOutputFile="$(JavaScriptOutputFile)"
LoggingType="HardcoreBringItOn"
ThreadCulture="en-us"
IsEvalIgnored="false" />
</Target>
</Project>
I get the following error:
Scripts.xml(14,11): error MSB4067: -element开发者_Python百科 under -element is unknown. (translated from swedish)
I'm using the 32bit .NET 2.0 version of MsBuild.
What's wrong?
You can't put an ItemGroup
in a target with MSBuild for .NET 2. You have to use the CreateItem
task or put it outside of the target. In your case you don't seem to need to dynamically create the JavaScriptFiles
item so you just have to put it outside of the target.
Outside:
<ItemGroup>
<JavaScriptFiles Include="..\..\site.se\javascript\javascript.js"/>
</ItemGroup>
<Target Name="CompressorTask">
<CompressorTask
JavaScriptFiles="@(JavaScriptFiles)"
ObfuscateJavaScript="True"
PreserveAllSemicolons="True"
DisableOptimizations="False"
EncodingType="utf-8"
DeleteJavaScriptFiles="false"
LineBreakPosition="-1"
JavaScriptOutputFile="$(JavaScriptOutputFile)"
LoggingType="HardcoreBringItOn"
ThreadCulture="en-us"
IsEvalIgnored="false" />
</Target>
Using CreateItem
:
<Target Name="CompressorTask">
<CreateItem Include="..\..\site.se\javascript\javascript.js">
<Output TaskParameter="Include" ItemName="JavaScriptFiles"/>
</CreateItem>
<CompressorTask
JavaScriptFiles="@(JavaScriptFiles)"
ObfuscateJavaScript="True"
PreserveAllSemicolons="True"
DisableOptimizations="False"
EncodingType="utf-8"
DeleteJavaScriptFiles="false"
LineBreakPosition="-1"
JavaScriptOutputFile="$(JavaScriptOutputFile)"
LoggingType="HardcoreBringItOn"
ThreadCulture="en-us"
IsEvalIgnored="false" />
</Target>
精彩评论