无点编译器退出代码-1 - MSBuild

时间:2012-12-10 19:50:09

标签: msbuild dotless

我尝试使用构建脚本来运行dotless.compiler.exe,将我的.less文件编译成构建中的.min.css:

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
  <!--    
    This MSBuild Script will compile all [*.less] files in the /CSS folder to their [*.min.css] counterparts.
    -->
  <ItemGroup>
    <LessFiles Include="Styles\*.less" />
  </ItemGroup>
  <Target Name="CompileDotlessCss" AfterTargets="AfterBuild">
    <ItemGroup>
      <Binaries Include="*.dll;*.exe"/>
    </ItemGroup>

    <!-- Compile dotLess CSS into minified full CSS -->
    <Exec Command="[MSBuild]\dotless.compiler.exe -m %(LessFiles.FullPath)  $([System.String]::Copy('%(LessFiles.FullPath)').Replace('.less','.min.css'))" />

  </Target>
</Project>

但是当我建立时,我得到了:

The command "[MSBuild]\dotless.compiler.exe -m C:\Source Control\MyProject\MyProject.Web\Styles\main.less  C:\Source Control\MyProject\MyProject.Web\Styles\main.min.css" exited with code -1.  

我怀疑它必须要么我的项目处于源代码控制之下,要么只是文件路径在&#34; Source Control&#34;夹。

如何将路径包装在引号中(因为命令本身在引号中)?

如果它是源控制因素并且因为文件被锁定而失败(我尝试使用签入的文件进行构建)..我该如何处理?我显然希望将我的项目保持在源代码管理之下。

1 个答案:

答案 0 :(得分:1)

您可以在MSBuild文件中使用""''互换。对于带空格的路径,最坏的情况可能需要像&quot;这样的XML转义。要获得超出退出代码的更好输出,请尝试将详细程度设置为detailed or diagnostic,这可能与[MSBuild]有关,不应该是$()属性吗?