2

I have been trying to call a process inside a docker container.

 ProcessStartInfo pStart = new ProcessStartInfo();
            pStart.FileName = fileName;
            pStart.Arguments = arguments;
            pStart.WindowStyle = ProcessWindowStyle.Hidden;
            pStart.CreateNoWindow = true;

            //#if DEBUG
            pStart.UseShellExecute = false;
            pStart.RedirectStandardOutput = true;
            pStart.RedirectStandardError = true;
            //#endif

            var process = new Process();
            process.StartInfo = pStart;
            process.Start();

            //#if DEBUG
            string output = process.StandardOutput.ReadToEnd();
            string error = process.StandardError.ReadToEnd();
            //#endif

but I keep on getting the same exception error

{System.ComponentModel.Win32Exception (8): Exec format 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) at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start()}

I have tried to farm out the work to a powershell script, but I get the same results.

This code works fine outside the Docker container...

Docker Images tried..

BASE: mcr.microsoft.com/dotnet/aspnet:3.1

BUILD: microsoft/dotnet-nightly:3.1-sdk, mcr.microsoft.com/dotnet/core-sdk, mcr.microsoft.com/dotnet/sdk:3.1

The whole point of this process is to target a nuget.exe file and preform an install command

if this code cant be fixed, but someone knows how I achive the install command a different way; that would be helpful too..

bearing in-mind the install command is dynamic and is determined by user input. (so, I dont think I can use a nuget.config)

Thanks

NickSx8
  • 21
  • 1
  • I have just tried to remove the arguments and the additional options for the ProcessStartInfo leaving only the filename (nuget.exe location) and I'm seeing the same error message. I now think the issue is with the Process being called inside the container, or the nuget.exe the debug continues...... – NickSx8 Feb 02 '22 at 17:20
  • Resolved......so, I needed to run apt update / apt -y install nuget. Then, I changed the fileName to "nuget" instead of the previous "/app/nuget.exe" and it worked... – NickSx8 Feb 02 '22 at 21:39

0 Answers0