C# Step Template on Linux fails

We are running a C# step template on a linux target.
It seems to fail with a pretty hard error about the exec format or not finding the scriptcs executable. Is this because it’s trying to compile to Windows but run on Linux? (Exec format error)

17:21:19   Error    |       Unable to execute /etc/octopus/.../Tools/Calamari.linux-x64/14.10.0/ScriptCS/scriptcs.exe, please ensure that /etc/octopus/.../Tools/Calamari.linux-x64/14.10.0/ScriptCS/scriptcs.exe is installed and is in the PATH.
17:21:19   Error    |       System.Exception: Error when attempting to execute /etc/octopus/.../Tools/Calamari.linux-x64/14.10.0/ScriptCS/scriptcs.exe: Exec format error
17:21:19   Error    |       ---> System.ComponentModel.Win32Exception (8): Exec format error
17:21:19   Error    |       at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
17:21:19   Error    |       at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
17:21:19   Error    |       at System.Diagnostics.Process.Start()
17:21:19   Error    |       at Calamari.Common.Features.Processes.SilentProcessRunner.ExecuteCommand(String executable, String arguments, String workingDirectory, Dictionary`2 environmentVars, String userName, SecureString password, Action`1 output, Action`1 error) in C:\buildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Features\Processes\SilentProcessRunner.cs:line 160
17:21:19   Error    |       --- End of inner exception stack trace ---
17:21:19   Error    |       at Calamari.Common.Features.Processes.SilentProcessRunner.ExecuteCommand(String executable, String arguments, String workingDirectory, Dictionary`2 environmentVars, String userName, SecureString password, Action`1 output, Action`1 error) in C:\buildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Features\Processes\SilentProcessRunner.cs:line 173
17:21:19   Error    |       at Calamari.Common.Features.Processes.CommandLineRunner.Execute(CommandLineInvocation invocation) in C:\buildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Features\Processes\CommandLineRunner.cs:line 28
17:21:19   Error    |       The command that caused the exception was: "/etc/octopus/.../Tools/Calamari.linux-x64/14.10.0/ScriptCS/scriptcs.exe" -script "/etc/octopus/.../Work/20200914172116-33364-2/Bootstrap.50c-4726-8c47-417af6b617ad.Script.csx" --  "we6crG3ReW2bdiYH6I7N5w=="
17:21:19   Verbose  |       Process /bin/bash in /etc/octopus/.../Work/20200914172116-33364-2 exited with code 255

I’ve checked my target and the scriptcs.exe file is indeed available at the location it specifies.

Any assistance you could provide would be appreciated.
If I’m missing something in my C# that’s also a possiblity. This is the first time I’ve attempted to use a C# script step. Unfortunately what I need to do is not easy using any of the other languages (Bash or Powershell) so it would be really useful if we could get this to work.

Thanks.

If I attempt to run the scriptcs.exe directly on the command line I receive the Exec format error

Is the executable compiled only for Windows?

Hi @ops,

scriptcs.exe is for windows, but I believe if you install Mono it should work.

Would you be able to install Mono and try? We recommend using Mono 5.14.x . As 5.16 has issues.

Please let me know if that works or if we need to dig in further.

Thanks,
Jeremy

1 Like

Ah nuts. I missed that snippet in the documentation about only being for Mono.
Looks like we might have to package up a small deployment executable.
All our apps are Net Core so we don’t want to have to install Mono in our currently clean environment just to get a small deployment step to work.

Thanks for the info.

You’re very welcome. Thanks for updating me.

I’m sorry I didn’t have better news for you.

I hope you have a great rest of your week.

Best,
Jeremy

1 Like