【问题标题】:How to prevent powershell merging msbuild properties?如何防止powershell合并msbuild属性?
【发布时间】:2016-03-31 08:56:53
【问题描述】:

我有这个 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 不要合并属性?

【问题讨论】:

    标签: powershell msbuild


    【解决方案1】:

    首先,我建议您使用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
    

    【讨论】:

      猜你喜欢
      • 2012-01-22
      • 1970-01-01
      • 2019-11-18
      • 2011-10-26
      • 2010-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多