Using Octopus Deploy Offline Package Drop to deploy a Windows Service, I am getting the following error log when deploying:
##octopus[stdout-default]
##octopus[stdout-verbose]
PowerShell Environment Information:
OperatingSystem: Microsoft Windows NT 6.3.9600.0
OsBitVersion: x64
Is64BitProcess: True
CurrentUser: XXX
MachineName: XXX
ProcessorCount: 2
CurrentDirectory: C:\Install\Octopus\XXX\OctopusApplications\XXX\XXX\XXX\XXX
CurrentLocation: C:\Install\Octopus\XXX.XXX.XXX.OfflinePackage.10.0.192-s
ync-only\OctopusApplications\XXX\XXX\XXX\XXX
TempDirectory: C:\Users\XXX\AppData\Local\Temp
HostProcessName: powershell
TotalPhysicalMemory: 16776628 KB
AvailablePhysicalMemory: 1785692 KB
##octopus[stdout-default]
. : The module â./OctopusApplicationsâ could not be loaded. For more information
, run âImport-Module ./OctopusApplicati
onsâ.
At C:\Install\Octopus\XXX.XXX.XXX.OfflinePackage.10.0.192-sync-only\Octopus
Applications\XXX\XXX\XXX\XXX\Bootstrap.Octopus.Features.WindowsService_AfterPreDeploy.ps1
:4299 char:3
Script â./OctopusApplications\XXX\XXX\XXX\XXX\Octo
pus.Features.WindowsService_AfterPreDeploy.ps1â returned non-zero exit code: 1
Whatâs going on here? The XXX_AfterPredeploy.ps1 script tries to find a powershell module named â./OctopusApplicationsâ? I donât have any custom pre or deployment scripts defined for the step (only have a post deploy script defined). Unfortunately the Octo
pus.Features.WindowsService_AfterPreDeploy.ps1 file seems to be deleted after the deployment attempt so I cannot inspect the file either.
Note that the same deployment works fine using online tentacle deployment. If I switch to Offline Package drop I get the above error. I have tried this on at least 2 different environments with the same result.
Whatâs going on here? The XXX_AfterPredeploy.ps1 script tries to find a powershell module named â./OctopusApplicationsâ? I donât have any custom pre or deployment scripts defined for the step (only have a post deploy script defined).
OctopusAplications seems to be a module thatâs sitting on your server(s) thatâs failing to load. The mystery is why it only fails to load when it gets imported via an Offline Package Drop(OPD). Couple of questions to aid in the troubleshooting:
Have you tried logging into one of the VMs where you are getting this error and looking for that module using Get-Module -ListAvailable to see where that module is at and if you can import it using import-module?
Is it possible that thereâs an Import-Module call in a Powershell Profile File thatâs being executed when you run the OPD.
If you create an ODP that just contains a single Powershell Script step that contains write-host "Hello world", do you get the same error?
Unfortunately the Octo
pus.Features.WindowsService_AfterPreDeploy.ps1 file seems to be deleted after the deployment attempt so I cannot inspect the file either.
Yes, we delete that bootstrap file after the deployment finishes.
There is no powershell module called OctopusApplications in any environment. Iâm not sure about my Powershell Profile File. If I run $PROFILE in powershell to get the path to the profile file I get a non-existing path, so not sure where to look.
I think if I create an ODP with just a Powershell script it would run fine, since the error only occurs when deploying a Windows Service. I have several IIS Web Applications that deploy fine during the ODP deploy (that each runs some powershell scripting in their postdeploy), itâs only the Windows Services that fails.
I figured out where the error comes from. In my offline package drop deployment target I have Applications Directory set to â./OctopusApplicationsâ. It seems like Octopus Deploy does not support relative paths here? I also tried â.\OctopusApplicationsâ with the same error. If I change to an absolute path the deployment works. Ideally I would like the Applications Directory to be relative to where I unzip the deployment package. Otherwise I will have to create quite a few Offline Package Drop deployment targets with different Applications Directories (one per tenant per environment pretty much).