Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm no expert, but I don't think it is possible to pass arguments to Invoke-Psake. Looking on the latest source for Psake the params for the Invoke-Psake function are:</p> <pre><code>param( [Parameter(Position=0,Mandatory=0)] [string]$buildFile = 'default.ps1', [Parameter(Position=1,Mandatory=0)] [string[]]$taskList = @(), [Parameter(Position=2,Mandatory=0)] [string]$framework = '3.5', [Parameter(Position=3,Mandatory=0)] [switch]$docs = $false ) </code></pre> <p>There are 4 parameters, your build file, a list of tasks, the .NET framework version, whether to output docs of your tasks. I'm new to powershell and psake and I'm trying to do the same thing, I am experimenting with doing something like this in my script to achieve the same thing:</p> <pre><code>properties { $environment = "default" } task PublishForLive -precondition { $environment = "Live"; return $true; } -depends Publish { } task PublishForStaging -precondition { $environment = "Staging"; return $true; } -depends Publish { } task Publish { Write-Host "Building and publishing for $environment environment" #Publish the project... } </code></pre> <p>Then calling psake with PublishForLive or PublishForStaging, whichever I need:</p> <pre><code>powershell -NoExit -ExecutionPolicy Unrestricted -Command "&amp; {Import-Module .\tools\psake\psake.psm1; Invoke-psake .\psake-common.ps1 PublishForLive }" </code></pre> <p>But it doesn't seem to work for me! Setting the $environment variable in the task precondition seems to have no effect. Still trying to make this work...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload