How to install custom assemblies for use in C# Script steps?

I’d like to setup a c# script step that runs on the Octopus server, and uses the Newtonsoft.Json C# package/assembly. How should this be installed?

I have tried adding a powershell script which executes “scriptcs -install Newtonsoft.Json”, but the scriptcs executable does not seem to be accessible. We also tried using running “scriptcs -install Newtonsoft.Json -g” (from the calamari directory), attempting to install the package globally, and the command ran successfully. However the assembly was still not able to be used from the C# step script. Any ideas?

Hi Cain,

Thanks for getting in touch.

When installing the Newtonsoft.Json package globally the only way I could make it work was to hard code the path to the dll in the global installation folder for Newtonsoft.Json.

According to the scriptcs docs the Global package folder is only for Modules so it won’t auto-load “normal” NuGet packages from it.

Unfortunately, I don’t think there is a way that you can do this unless you install a Tentacle on your Octopus server and then put your csx file in a package and use a Deploy package step with a pre-deploy step that runs <pathtoscriptcs> -i Newtonsoft.Json so that it is then available when your main script is executed.

Sorry for not having a better solution than this for you.

Thank you and best regards,
Henrik

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.