Custom C# Deployment script error

I’m trying to do a custom C# script deployment and running into errors.

#r "System.IO.Compression.dll"
#r "System.IO.Compression.FileSystem.dll"
#r "System.Xml.Linq.dll"
using System;
using System.IO;
using System.IO.Compression;
using System.Xml.Linq;
Console.WriteLine("Test ....");

I’m getting [FileNotFoundException] Assembly not found error.

10:40:57 Verbose | Executing 'G:\Octopus\Work\20170516144056-24\Script.csx’
10:40:59 Info | ERROR: Error executing script ‘G:\Octopus\Work\20170516144056-24\Bootstrap.198-4dca-ae1e-443f3b880a60.Script.csx’ [FileNotFoundException] Assembly not found.
10:40:59 Verbose | Updating manifest with output variables
10:40:59 Verbose | Updating manifest with action evaluated variables
10:40:59 Fatal | The remote script failed with exit code 1
10:40:59 Verbose | at Octopus.Worker.Scripting.ScriptResult.EnsureSuccessful() in Z:\buildAgent\workDir\eec88466c176b607\source\Octopus.Worker\Scripting\ScriptResult.cs:line 97
| at Octopus.Server.Orchestration.Deploy.Script.ServerScriptActionHandler.Execute(ActionCommand command, Machine machine) in Z:\buildAgent\workDir\eec88466c176b607\source\Octopus.Server\Orchestration\Deploy\Script\ServerScriptActionHandler.cs:line 62
| at Octopus.Server.Orchestration.Deploy.DeploymentTaskController.<>c__DisplayClass28_0.b__0() in Z:\buildAgent\workDir\eec88466c176b607\source\Octopus.Server\Orchestration\Deploy\DeploymentTaskController.cs:line 323
| at Octopus.Server.Orchestration.Deploy.DeploymentTaskController.ExecuteWithTransientErrorDetection(Action action, Machine machine) in Z:\buildAgent\workDir\eec88466c176b607\source\Octopus.Server\Orchestration\Deploy\DeploymentTaskController.cs:line 428
| at Octopus.Server.Orchestration.Deploy.DeploymentTaskController.ExecuteActionAndInitLoggingContext(PlannedStep step, Machine machine, PlannedAction action) in Z:\buildAgent\workDir\eec88466c176b607\source\Octopus.Server\Orchestration\Deploy\DeploymentTaskController.cs:line 321
10:40:59 Fatal | Deploy Risk Scheduler on the Octopus Server

This used to work. We just upgraded to 3.13.3 and started getting these errors.

Can you guys point me in the right direction?

Hi Vasu,

Thank you for getting in touch. Which version where you using previously? The change could be due to us not using System.IO.Compression.FileSystem.dll anymore internally, or the machine you are now running it on not having it in the GAC. System.Xml.Linq.dll is in the GAC, so that should work.

I suggest using loading the dlls using the full file path (eg #r c:\bin\System.IO.Compression.dll). You could either copy the required assemblies on their manually, or use Octopus do deploy them via a package. Alternative you could package the DLLs and the script into a package and use the Octopus Run script from package functionality.

Hope that helps,

Robert W

We were on 3.3.6, so I’m not sure if the latest version uses a different version of ScriptCs. I found the following github issue regarding references in ScriptCs.

I got it to work by changing the references to the following:

#r “System.IO.Compression”
#r “System.IO.Compression.FileSystem”
#r “System.Xml.Linq”

using System.IO;
using System.IO.Compression;
using System.Xml.Linq;

Thanks
Vasu