Search code examples
powershellmsbuildpsake

Psake - How to activate /m switch for MSBuild?


Hi I'm trying to compile my project using MSBuild & Psake but I have problems passing the /m to MSBuild. Here is my code:

Exec {
    MSBuild $solutionFile "/p:Configuration=$buildConfiguration;Platform=$buildPlatform;OutDir=$tempPath /m"
}

MSBuild Output:

"C:\Users\mabre\Source\Psake\Psake.sln" (default target) (1) -> "C:\Users\mabre\Source\Psake\src\Psake.Library\Psake.Library.xproj" (default target) (5) -> C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : Could not find a part of the path 'C:\Users\mabre\Source\Psake.build\temp \m\src\Psake.Library\obj\Release\netstandard1.6'. [C:\Users\mabre\Source\Psake\src\Psake.Library\Psake.Library.xproj]

0 Warning(s)
4 Error(s)

Note that the /m is part of the output path now

Error: 7/22/2016 12:39:04 AM: At C:\Users\mabre.nuget\packages\psake\4.6.0\tools\psake.psm1:156 char:17 + throw ("Exec: " + $errorMessage) +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [<<==>>] Exception: Exec: Error executing command MSBuild $solutionFile "/p:Configuration=$buildConfiguration;Platform=$buildPlatform;OutDir=$tempPath /m" . Build exit code: 1

Thanks in advance


Solution

  • Try it without putting all of the arguments in one string. Here are two examples of what my MSBuild tasks look like in pSake:

    Task CleanProject -depends RestoreNuget {
        Exec {
            msbuild `
                "$VisualStudioSolutionFile" `
                /target:Clean `
                /property:Configuration=$Configuration `
                /verbosity:quiet
        }
    }
    

    and...

    Task BuildProject -depends DeleteBinAndObjFolders {
        Exec {
            msbuild `
                "$ProjectPath" `
                /target:Rebuild `
                /property:Configuration=$Configuration `
                /property:OutDir="$ProjectBuildArtifactsPath" `
                /property:UseWPP_CopyWebApplication=True `
                /property:PipelineDependsOnBuild=False `
                /property:WebProjectOutputDir="$WebBuildArtifactsPath" `
                /verbosity:quiet
        }
    }
    

    Note that I put " around any variables that I think may contains spaces.

    So try something like this for yours:

    Exec {
        MSBuild "$solutionFile" /p:Configuration=$buildConfiguration;Platform=$buildPlatform;OutDir="$tempPath" /m
    }