0

I'm trying to use a build script to run the dotless.compiler.exe to compile my .less files into .min.css on build:

<?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>

But when I build I get:

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.  

I suspect it has to do either with my project being under source control or simply the fact that the file path has a space in the "Source Control" folder.

How can I wrap the path in quotes (since the command itself is in quote)?

If it's the source control factor and it fails because the files are locked (I tried building with the file checked in).. how do I deal with this? I obviously want to keep my project under source control.

madth3
  • 7,275
  • 12
  • 50
  • 74
parliament
  • 21,544
  • 38
  • 148
  • 238

1 Answers1

1

You can use "" and '' interchangeably in MSBuild files, inc. for paths with spaces, worst cases might require XML escapes like &quot;. For better output beyond exit code try to up verbosity to detailed or diagnostic, may be it's something to do with [MSBuild], shouldn't it be a $() property?

Ilya Kozhevnikov
  • 10,242
  • 4
  • 40
  • 70