我想运行一个自定义任务,在打包应用程序(.net mvc 3)之前将.less文件编译为.css。
我没有很多创建MSBUILD脚本的经验,所以通过在线阅读我想出了下面的代码。它有效,但我觉得我应该有一种方法可以跳过ItemGroup显式声明,并指示脚本查找“Skins文件夹下的任何文件夹”。这有可能吗?
<Target Name="CompileLessToCss" BeforeTargets="Package">
<PropertyGroup>
<DotLessCompiler>..\..\Libraries\dotless\dotless.Compiler.exe</DotLessCompiler>
<!--Skin Paths -->
<ApplicationSkins>Content\Skins\</ApplicationSkins>
<MobileSkins>Areas\Mobile\Content\Skins\</MobileSkins>
<!--Style FileNames -->
<LessPath>\less\main.less</LessPath>
<CssPath>\css\main.min.css</CssPath>
</PropertyGroup>
<ItemGroup>
<Skins Include="$(ApplicationSkins)Blue"/>
<Skins Include="$(MobileSkins)Blue"/>
<Skins Include="$(ApplicationSkins)Red"/>
<Skins Include="$(MobileSkins)Red"/>
<Skins Include="$(ApplicationSkins)Yellow"/>
<Skins Include="$(MobileSkins)Yellow"/>
</ItemGroup>
<!-- Compiling Less Files -->
<Message Text="Compiling Less For Skins: @(Skins)"/>
<Exec Command="$(DotLessCompiler) -m "%(Skins.FullPath)$(LessPath)" "%(Skins.FullPath)$(CssPath)"" />