예제 #1
0
        public NetCoreProgram(string executable, string arguments, Action <ProcessStartInfo> setupStartInfo)
        {
            if (!NetCoreProgram.IsNetCoreAvailable())
            {
                UnityEngine.Debug.LogError("Creating NetCoreProgram, but IsNetCoreAvailable() == false; fix the caller!");
            }
            ProcessStartInfo processStartInfo = NetCoreProgram.CreateDotNetCoreStartInfoForArgs(CommandLineFormatter.PrepareFileName(executable) + " " + arguments);

            if (setupStartInfo != null)
            {
                setupStartInfo(processStartInfo);
            }
            this._process.StartInfo = processStartInfo;
        }
예제 #2
0
        public static bool IsNetCoreAvailable()
        {
            bool result;

            if (!NetCoreProgram.s_NetCoreAvailableChecked)
            {
                NetCoreProgram.s_NetCoreAvailableChecked = true;
                ProcessStartInfo si      = NetCoreProgram.CreateDotNetCoreStartInfoForArgs("--version");
                Program          program = new Program(si);
                try
                {
                    program.Start();
                }
                catch (Exception ex)
                {
                    UnityEngine.Debug.LogWarningFormat("Disabling CoreCLR, got exception trying to run with --version: {0}", new object[]
                    {
                        ex
                    });
                    result = false;
                    return(result);
                }
                program.WaitForExit(5000);
                if (!program.HasExited)
                {
                    program.Kill();
                    UnityEngine.Debug.LogWarning("Disabling CoreCLR, timed out trying to run with --version");
                    result = false;
                    return(result);
                }
                if (program.ExitCode != 0)
                {
                    UnityEngine.Debug.LogWarningFormat("Disabling CoreCLR, got non-zero exit code: {0}, stderr: '{1}'", new object[]
                    {
                        program.ExitCode,
                        program.GetErrorOutputAsString()
                    });
                    result = false;
                    return(result);
                }
                NetCoreProgram.s_NetCoreAvailable = true;
            }
            result = NetCoreProgram.s_NetCoreAvailable;
            return(result);
        }