使用 .NET core 在 MAC 操作系统中启动 Process.Start 会出现错误 - 没有这样的文件或目录

Rab*_*abi 5 c# macos .net-core

我正在创建一个 .NET Core 控制台应用程序来运行命令。

public bool RunCommand()
{
    try
    {
        var procStartInfo = new ProcessStartInfo("exec", "cal")
        {
            RedirectStandardOutput = true,
            UseShellExecute = false,
            CreateNoWindow = false
        };

        var proc = new Process { StartInfo = procStartInfo };
        proc.Start();

        // Get the output into a string
        output = proc.StandardOutput.ReadToEnd();

        return proc.ExitCode == decimal.Zero ? true : false;
    }
    finally
    {
        // do something
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误 -

Unhandled Exception: System.ComponentModel.Win32Exception: No such file or directory
   at System.Diagnostics.Process.ResolvePath(String filename)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at HockeyApp.Enablers.IosCodeSign.ProcessManager.RunCommand(String command, String& output)
   at HockeyApp.Enablers.IosCodeSign.Program.Main(String[] args)
Run Code Online (Sandbox Code Playgroud)

我什至尝试过 -

var procStartInfo = new ProcessStartInfo("cal")
Run Code Online (Sandbox Code Playgroud)

没有运气。

我缺少什么吗?

Ric*_*ana 5

我只是删除"exec",构造函数中的 ,在var之前添加output,代码也可以工作,可在https://github.com/fontanaricardo/RunCommand上找到