Error in Bootstrap.Octopus.AzureContext.ps1: $MyInvocation.MyCommand.Path is null

Hi there

I’m trying to execute an Azure PowerShell deployment step, which is consistently failing with the error

Split-Path : Cannot bind argument to parameter 'Path' because it is null.
At C:\ProgramData\Octopus\Work\20161013155154-9\Bootstrap.Octopus.AzureContext.ps1:1572 char:25
+ $scriptDir = Split-Path $MyInvocation.MyCommand.Path
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData: (:) [Split-Path], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SplitPathCo
The remote script failed with exit code 1

The script that I’ve added to the deployment step is really simple:

Invoke-Psake `
    -framework 4.6 `
    -buildFile "Scripts\deploy.ps1" `
    -properties @{ "ClusterName"=$EnvironmentShortName }

Invoke-Psake is defined in a script module, which is a copy-paste job on this file. I get the exact same result (no output) if I add a Write-Host statement at the start of my script.

I’ve attached the log file to this post. I’m using v3.4.10.

ServerTasks-738.log.txt (4 KB)

In fact, if I comment out the Invoke-psake command and just leave the script as a simple Write-Host statement, I see exactly the same behaviour. Is this step broken somehow, or missing a piece of configuration perhaps?

Tried upgrading to 3.4.12 - same result.

Some further investigation indicates that it’s the Psake Script Module that’s somehow interfering with the process - not sure why right now.

Hi Alastair,

Thanks for reaching out! Does seem like there’s something wrong with Psake or the day its being loaded. What I would try is, instead of loading it from the Octopus Script Module, simply installing it on the server on one of the paths of $env:PsModulePath and execute it from there. Just to take parts out of the equation and see if it works that way.

Let me know what you find.


Thanks Dalmiro. I reliased that we don’t actually need psake for this part of our CD process at all, so I’ve removed that dependency and it’s working very nicely now =) Please consider the request resolved.