I would like to inject command line parameters into my psake build script like: .\build.ps1 Deploy environment="development"
But psake will treat every argument as a Task and will answer "task does not exists"
Is it possible to inject command line arguments in psake?
build.ps1 -->
Import-Module '.\psake.psm1'
Invoke-psake '.\tasks.ps1' $args
Remove-Module psake
The latest release of psake now supports passing parameters to Invoke-psake, e.g.
Invoke-psake .\parameters.ps1 -parameters @{"p1"="v1";"p2"="v2"}
This feature has just been added. :)
A global variable will solve my problem for now and with only one reference to $global:arg_environent it will be easy to change if i find a better way to inject the properties.
build.ps1
param(
[Parameter(Position=0,Mandatory=0)]
[string]$task,
[Parameter(Position=1,Mandatory=0)]
[string]$environment = 'dev'
)
clear
$global:arg_environent = $environment
Import-Module .\psake.psm1
Invoke-psake tasks.ps1 $task
Remove-Module psake
tasks.ps1
properties {
$environment = $global:arg_environent
}
task default -depends Deploy
task Deploy {
echo "Copy stuff to $environment"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With