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 output I get:
Microsoft .NET Core Shared Framework Host
Version : 1.1.0 Build : 928f77c4bc3f49d892459992fb6e1d5542cb5e86
Usage: dotnet [common-options] [[options] path-to-application]
Common Options: --help Display .NET Core Shared Framework Host help. --version Display .NET Core Shared Framework Host version.
Options: --fx-version Version of the installed Shared Framework to use to run the application.
--additionalprobingpath Path containing probing policy and assemblies to probe for.Path to Application: The path to a .NET Core managed application, dll or exe file to execute.
If you are debugging the Shared Framework Host, set 'COREHOST_TRACE' to '1' in your environment.
To get started on developing applications for .NET Core, install the SDK from: http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
So I seems exacly like run command dotnet with no dll path argument.
You need to escape the argument to
-c
so that it is one single argument:i change something and make the message can be output sync
}