Octopus Script Step Error: "Common Language Runtime detected an invalid program"

Octopus Script Step Error: "Common Language Runtime detected an invalid program"

You might run into the following error when deploying with Octopus and one of your tasks is executing a C# script (ScriptCS) on the target machine.

octopus script error

ERROR: Script execution failed. [InvalidProgramException] Common Language Runtime detected an invalid program.
Exit code: 1
The remote script failed with exit code 1

This is most likely because .NET 4.5.2 is not installed on the machine. If you install that the error should go away.

There's a bit more info available on the following links: