Hi Octopus Team,
We are having issues with Octopus Offline deployment where one of the powershell that has a Get-WebSite command fails with the following error.
Get-Website : Could not load file or assembly 'Microsoft.IIS.PowerShell.Framework' or one of its dependencies. The system cannot find the file specified.
We are on Octopus version - 3.0.21.
Powershell version - 4.0
Prior to upgrade to v3.0.21 we were on v3.0.16 and had two successful Offline deployments. Did any changes in the later versions cause this to break.
Please note that the execution policy is set to unrestricted. Our script imports the WebAdministration Module with ErrorAction SilentlyContinue
Some of the thing that we tried :-
- Explicitly load the assembly “Microsoft.IIS.Powershell.Framework” dll.
- Executing the Get-WebSite command from C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe as an admin.
Meanwhile we also found - Octopus Support
The solution suggested in this discussion did solve the issue, but doing this would be tedious as we have to manually change these scripts every time we do offline deployments on this server.
This step does works without issues for all other servers and online deployments.
Thanks in advance.
I’m sorry that experiencing this issue. It is a pesky one.
I understand it isn’t specific to Octopus. It can occur in stand-alone PowerShell.
The only change we made between those versions that I could imagine affecting this is adding the
-NonInteractive switch when we invoke
PowerShell.exe. I’m not sure why that would make it more likely to occur, but who knows?
Which solution worked for you? There seem to have been a few suggested. Perhaps we can find a less invasive option.
The solution that worked is to add a try-catch block around the Get-WebSite call. When doing offline deployment, a copy of the script gets created for each of the services that we deploy and manually changing this for each of the services is tedious. This is blocking our offline deployments. Please prioritize this issue at your end and advise alternate solution.
The way we load the IIS cmdlets (to avoid this problem) is:
Add-PSSnapin WebAdministration -ErrorAction SilentlyContinue
Import-Module WebAdministration -ErrorAction SilentlyContinue
It may be worth seeing if this works for you?
Does it work if you execute the failing script yourself on those machines (i.e. not via the Octopus offline cmd file)?
Alternatively, if the try/catch resolves the problem, rather than adding it manually, can you not add it to the actual script? It wouldn’t do any harm to have it included in non-offline deployments.
The IIS cmdlets are loaded with the ErrorAction SilentlyContinue and we did not try executing these scripts directly.
We want to keep the try/catch workaround as the last option. But I wanted to know if there have been any updates related to this in the recent releases which may have caused this issue to go away.
Appreciate your help.
No. As far as I know, there haven’t been any changes that would have resolved this issue. PowerShell 5 is soon to be released, it may be worth seeing if the issue still occurs with it installed?
I experience this issue on Windows Server 2008 R2 with PowerShell 5 in Octopus deployments. I can eliminate this issue by reverted back to PowerShell 2, but this is very undesirable. I haven’t tested with PS3 or PS4, but that wouldn’t be our desired end-state either.
Thanks for getting in touch. For me to give you the best support possible, could I please ask you to create a new thread, make it private, and send through the raw deployment log for the failing deployment?
Also could you confirm which version of PowerShell 5/WMF 5 you installed on that server? Microsoft shipped a broken version last year, then pulled the release, and only just re-released it late in Feb 2016.
We try to ensure Octopus works well with PowerShell 2-5, but there have been some weird edge cases appearing with earlier PS/WMF 5 releases.
Hope that helps!