2016-07-22 71 views
1

嗨我試圖編譯我的項目使用MSBuild & Psake但我有問題將/ m傳遞給MSBuild。這裏是我的代碼:Psake - 如何激活/ m切換爲MSBuild?

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

的MSBuild輸出:

"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) 

注意,/M是輸出路徑的一部分,現在

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

在此先感謝

+0

你嘗試把'/ M'第一,而不是過去的,所以它不會受到什麼Psake會後補充的嗎? – stijn

回答

3

嘗試一下,不要將所有參數放在一個字符串中。下面是我的MSBuild任務看起來像在pSake兩個例子:

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

和...

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

注意,我把"左右,我認爲可能包含空格的變量。

所以嘗試這樣的你:

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

Pefect,謝謝! – Miguel