【发布时间】:2012-01-22 11:35:12
【问题描述】:
我有一个属性来指定构建驱动器:
<PropertyGroup>
<BuildDrive Condition="'$(BuildDrive)'==''">Y:</Group>
</PropertyGroup>
如果我想使用批处理文件更改构建驱动器,我可以这样做:
@echo off
set buildDrive=H:
:: Then call MSBuild
Msbuild /t:BuildTarget %Projectfile% %Logger%
现在我想使用 PowerShell 实现同样的目标。
我在我的 PowerShell 脚本 build.ps1 中尝试如下:
$BuildDrive=H:
MSbuild /t:BuildTarget $ProjectFile $Logger
但它不支持通过 $BuildDrive 提供的驱动器号。 我知道如果按如下方式传递一个参数就可以实现,但是当属性数量更多时,这种方法并不好用。
$BuildDrive=H:
Msbuild /t:BuildTarget /p:BuildDrive=$BuildDrive $projectfile $logger
如何通过 PowerShell 传递 PropertyGroup 值?
【问题讨论】:
标签: powershell msbuild powershell-2.0 msbuild-4.0