Problem deploying web application to IIS

I have an existing Octopus Deploy setup that deploys several web applications across our servers successfully. I have just set up a new deployment but when I try to deploy the site it gives the following error message:

foreach-object : You cannot call a method on a null-valued expression.
July 12th 2017 14:06:49Error
At C:\Octopus\Applications\DEV\EDWAccess\1.1.6817_4\Octopus.Features.IISWebSite
July 12th 2017 14:06:49Error
_BeforePostDeploy.ps1:86 char:29'

I thought that there was a problem so I played around with it for a while but got the same error every time. As a testing step I cloned an existing project, changed the port number and deployed it only for it to fail for the same reason. I’ve searched the net quite a bit but all it says is that I need to define bindings, which I have done (see attached image)

I’m a bit stuck because I am deploying code that is already deployed to a machine that is already running the code using a setup where the only difference is the port number it’s running on so I can’t think of anything else. I’ve upgraded to version 3.15.4 but it hasn’t gone away.

I’ve attached the raw log of the deployment.

ServerTasks-25292.log.txt (8 KB)

I couldn’t upload both files at once so here’s the image of the binding setup

Hi Stuart, thanks for reaching out.

Can you please enable the settings to write variables to the log file using the instructions at https://octopus.com/docs/how-to/debug-problems-with-octopus-variables#DebugproblemswithOctopusvariables-Writethevariablestothedeploymentlog and attach the new log file. These additional variables will aid us in debugging the issue.

Regards
Matt C

Thanks for your reply,

please see the output attached.

Cheers

Stu

ServerTasks-25383.log.txt (61 KB)

Hi Stuart, thanks for providing those log files.

The line of code $bindingString.Split("|") | foreach-object { is being reported as being on line 86 of Octopus.Features.IISWebSite_BeforePostDeploy.ps1. This means that the version of Calamri is quite old - late 2015 was the last version of Calamari that included a version of the Octopus.Features.IISWebSite_BeforePostDeploy.ps1 file with that particular code at line 86.

08:45:21   Error    |       foreach-object : You cannot call a method on a null-valued expression.
08:45:21   Error    |       At C:\Octopus\Applications\DEV\EDWAccess\1.1.6817_6\Octopus.Features.IISWebSite
08:45:21   Error    |       _BeforePostDeploy.ps1:86 char:29
08:45:21   Error    |       + $bindingString.Split("|") | foreach-object {

Your Calamri may be out of date, you may have specified a particular build of Calamari be used that is quite old, or you may have included the Octopus.Features.IISWebSite_BeforePostDeploy.ps1 file, overriding the Calamari version.

If you do a health check you should be able to see the version of Calamari being used. I have included a screenshot as an example.

Can you please run the health check and paste in the version of Calamari that is being used. We can use this information to work out why such an old script is being run.

Regards
Matt C

Hi Matt,

your message rang some bells and made me remember this ticket: http://help.octopusdeploy.com/discussions/problems/40907-power-shell-errors-iiswebsite_beforepostdeployps1-after-upgrading-from-26-to-314

from which we were running a version of calamari V3.2.something - the one uploaded onto the ticket.

I’ve removed the config and updated the tentacle and it’s all working well again.

Thanks so much for your help

Stu