Hi,
We have just started looking into migrating from Redgate DM to Octopus. In our deployment we rely on some powershell scripts (and some exe) . However., for some reason, when the scripts are run by Octopus, powershell fails to load .Net 4.0 assemblies ( example: When calling System.IO.File.ReadLines we get [System.IO.File] doesn’t contain a method named ‘ReadLines’) and works fine with Redgate. Any idea ?
Hi Matt,
When Deployment Manager runs PowerShell, it does so by hosting the PowerShell runtime within the application, so it gets the same version of .NET inside PowerShell.
When Octopus calls PowerShell, we do so by just calling PowerShell.exe.
Could you use the Octopus Script Console to write the value of PSVersionTable? This will help us to see which version of PowerShell is being called by default.
Paul
Hi Paul,
Thanks for your reply. Psversiontable shows powershell version 2.0 and CLR 2.0.50727.3662, which makes sense considering the way Octopus works. Is there a way to change PS settings in Octopus ? (.Net version targeted is 4.0). Thanks,
Hi Matt,
Thanks for the reply. To force PowerShell 4.0, the second answer on this page should help:
You’ll need to use the Script Console to find the value of $PSHome so that you know where to put the config file.
Paul
Thanks Paul.