簡體   English   中英

如何防止Powershell合並msbuild屬性?

[英]How to prevent powershell merging msbuild properties?

我有這個powershell腳本

$msbuildSettings="/p:Configuration=Release /p:VisualStudioVersion=12.0";
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe ..\Sol.sln /t:"Clean;Admin" $msbuildSettings

導致此錯誤的原因

The specified solution configuration "Release /p:VisualStudioVersion=12.0|Mixed Platforms" is invalid.

Msbuild認為

/p:Configuration=Release /p:VisualStudioVersion=12.0

是一個屬性。

如果我不使用變量msbuildsettings,則構建有效,即

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe ..\WeConnectSol.sln /t:"Clean;WeConnectAdmin" /p:Configuration=Release /p:VisualStudioVersion=12.0

如何告訴Powershell不要合並屬性?

首先,我建議您使用Join-Path$env:windir變量來確定msbuild路徑:

$msbuild = Join-Path $env:windir 'Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe'

另外,我將使用數組來定義參數:

$parameters = @(
    '..\Sol.sln', 
    '/t:"Clean;Admin"', 
    '/p:Configuration=Release', 
    '/p:VisualStudioVersion=12.0')

最后使用splatting傳遞參數:

& $msbuild @parameters

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM