使用psake 4.5.0,我尝试以default.ps1
多种不同的方式运行我的文件,同时传递-properties
和-parameters
,但这些值在-script的根范围内被忽略。.ps1
执行相对(在子文件夹中使用 psake):
.\psake-4.5.0\psake.ps1 .\default.ps1 BuildSolution -properties @{"a"="a";"b"="b";"c"="c";"d"="d"} -parameters @{"w"="w";"x"="x";"y"="y";"z"="z"}
使用导入的模块执行:
Import-Module .\psake-4.5.0\psake.psm1
Invoke-Psake .\default.ps1 BuildSolution -properties @{"a"="a";"b"="b";"c"="c";"d"="d"} -parameters @{"w"="w";"x"="x";"y"="y";"z"="z"}
通过已安装的 Chocolatey-package 执行:
psake .\default.ps1 BuildSolution -properties "@{'a'='a';'b'='b';'c'='c';'d'='d'}" -parameters "@{'w'='w';'x'='x';'y'='y';'z'='z'}"
通过执行cmd.exe
:
psake-4.5.0\psake.cmd default.ps1 BuildSolution -properties "@{'a'='a';'b'='b';'c'='c';'d'='d'}" -parameters "@{'w'='w';'x'='x';'y'='y';'z'='z'}"
现在,default.ps1
只是调试所有这些值:
// Since "properties" doesn't get populated, I also try "Param"
Param(
$w = $w, // Trying to populate from passed param
$x = $null, // Trying to default to null-value
$y // Trying another syntax, hoping for population
// "$z" left out, hoping for population
)
properties {
$a = $a
$b = $null
$c
}
Write-Host "a: $a"
Write-Host "b: $b"
Write-Host "c: $c"
Write-Host "d: $d"
Write-Host "w: $w"
Write-Host "x: $x"
Write-Host "y: $y"
Write-Host "z: $z"
Task BuildSolution -Depends Clean {
Write-Host "Running BuildSolution"
}
Task Clean {
Write-Host "Running Clean"
}
在所有情况下,输出都是:
a:
b:
c:
d:
w:
x:
y:
z:
传递properties
和/或parameters
psake 的正确语法是什么?