Execute bash command from .NetCore with arguments
I am trying to run one .NetCore program from another.
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "sh";
psi.Arguments = "-c dotnet /home/myuser/PublishOutput/myprogram.dll";
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
Process proc = new Process
{
StartInfo = psi
};
proc.Start();
string error = proc.StandardError.ReadToEnd();
if (!string.IsNullOrEmpty(error))
return "error: " + error;
string output = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
return output;
As an output, I get:
Microsoft .NET Core Shared Framework Host
Version: 1.1.0 Build: 928f77c4bc3f49d892459992fb6e1d5542cb5e86
Usage: dotnet [common-options] [[options] path-to-application]
General options: --help Display .NET Core General host support. --version Display The version of the .NET Core Shared Framework Host.
Parameters: --fx-version Installed version The common platform used to run the application.
--additionalprobingpath Path containing the probing and build policy for searching.Application Path: The path to the managed .NET Core application, dll, or exe to execute.
If you are debugging a shared platform host, set 'COREHOST_TRACE' to "1" in your environment.
To get started developing apps for .NET Core, install the SDK from: http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
So, I look as flawless as running dotnet command without path dll argument.
source to share