Question

In Visual Studio 2012 I was running the following Post-Build task to compile and combine my LESS files:

$(MSBuildBinPath)\msbuild.exe "$(ProjectDir)MSBuildSettingsLess.xml"

With my MSBuildSettingsLess.xml looking like:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
    <Target Name="CompileDotlessCss">
        <ItemGroup>
            <Binaries Include="*.dll;*.exe"/>
        </ItemGroup>

        <!-- Compile dotLess CSS into minified full CSS -->
        <Exec Command="$(SolutionDir)..\Tools\dotless.compiler.exe $(ProjectDir)..\GMHC\Content\less\responsive.less $(ProjectDir)..\GMHC\Content\bootstrap-responsive.less.css"/>
        <Exec Command="$(SolutionDir)..\Tools\dotless.compiler.exe $(ProjectDir)..\GMHC\Content\less\bootstrap.less $(ProjectDir)..\GMHC\Content\bootstrap.less.css"/>
    </Target>
</Project>

In Visual Studio 2013, that fails with the following error:

The command "C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe "C:\Users\Administrator\Documents\Projects\MedicalMissions\GMHC\MSBuildSettingsLess.xml exited with code 9009.

The output windows shows the following:

1> 'C:\Program' is not recognized as an internal or external command,
1> operable program or batch file.
1> C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: The command "C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe "C:\Users\Administrator\Documents\Projects\MedicalMissions\GMHC\MSBuildSettingsLess.xml"

Any idea why it is failing or how to get to the bottom of it?

Was it helpful?

Solution

The answer was actually pretty simple, I just had to surround the call in quotes. So the new Post-Build task is:

"$(MSBuildBinPath)\msbuild.exe" "$(ProjectDir)MSBuildSettingsLess.xml"

Looks like it is backward compatible with VS 2012 as well.

OTHER TIPS

You may need quotes in your msbuild defintion (.proj) file.

Generic example:

  <Exec Command="&quot;c:\Folder With Spaces\myfile.exe&quot;"/>  

The same problem occurred for me but i am using space in folder. The solution is working when i remove the space.

Do:
D:\MyDetailsMuthuvelF\Project_Document\

Don't:
D:\My Details Muthuvel F\Project_Document\
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top