1

我有一个属性来指定构建驱动器:

<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

如何PropertyGroup通过 PowerShell 传递值?

4

1 回答 1

5

您正在设置环境变量。这些可作为 MSBuild 中的属性使用。

您可以在 PowerShell 中执行以下操作:

$env:BuildDrive="H:"
于 2011-12-17T05:03:16.507 回答