So, I am working on a utility to create a GUI for cloning, updating, and ultimately compiling a GitHub project. I have already created a script which does the same general thing via an MSYS2 terminal directly, but I am having trouble getting those same type of commands to work in a C# GUI. I have had luck calling that same script from within the GUI at the click of a button, but I would like to be able to package everything as a standalone executable rather than have to bundle it with a script, though I will if that's what it comes down to in the end.
Here's what I have now (with some if statements removed for controlling additional arguments):
ProcessStartInfo compileStart = new ProcessStartInfo();
compileStart.FileName = this.textMSYS2.Text + "\\usr\\bin\\mintty.exe";
this.outputText.Text += "Configuring MSYS2 process...\n";
compileStart.Arguments += "-h always /bin/env MSYSTEM=MINGW64 /bin/bash -l ";
compile.StartInfo = compileStart;
compile.Start();
compile.WaitForExit();
As it currently stands, it fails if I add either pacman
or make
calls or even a simple dir
call. The errors returned look like this:
/usr/bin/make: /usr/bin/make: cannot execute binary file
/bin/env: Exit 126.
If however I make it a call to my ./install.sh
script, the script executes without a problem and the MINGW64 window even remains open after it is done. Any insight as to how I can get this to work without having to package a script with it as well would be appreciated.
I think you're missing a -c
alongside -l
there. Bash has three modes of operation (maybe more, but that's irrelevant at the moment):
-i
: interactive; accepts individual commands supplied through standard input-c FOO
: run command FOO
foo.sh
: interpret a shell script foo.sh
In your case, you're supplying commands, but Bash is trying to interpret them as names of shell script files.