private static ProcessStartInfo CreateDotNetCoreStartInfoForArgs(string arguments) { string text = Paths.Combine(new string[] { NetCoreProgram.GetSdkRoot(), "dotnet" }); if (Application.platform == RuntimePlatform.WindowsEditor) { text = CommandLineFormatter.PrepareFileName(text + ".exe"); } ProcessStartInfo processStartInfo = new ProcessStartInfo { Arguments = arguments, CreateNoWindow = true, FileName = text, WorkingDirectory = Application.dataPath + "/.." }; if (Application.platform == RuntimePlatform.OSXEditor) { string text2 = Path.Combine(Path.Combine(Path.Combine(NetCoreProgram.GetNetCoreRoot(), "NativeDeps"), "osx"), "lib"); if (processStartInfo.EnvironmentVariables.ContainsKey("DYLD_LIBRARY_PATH")) { processStartInfo.EnvironmentVariables["DYLD_LIBRARY_PATH"] = string.Format("{0}:{1}", text2, processStartInfo.EnvironmentVariables["DYLD_LIBRARY_PATH"]); } else { processStartInfo.EnvironmentVariables.Add("DYLD_LIBRARY_PATH", text2); } } return(processStartInfo); }
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; }
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); }
internal static int Run(string arguments, string workingDir, out string stdOut, out string stdErr) { var assemblyUpdaterProcess = new NetCoreProgram(AssemblyUpdaterPath(), arguments, psi => { psi.CreateNoWindow = true; psi.RedirectStandardError = true; psi.RedirectStandardOutput = true; psi.WorkingDirectory = workingDir; psi.UseShellExecute = false; }); assemblyUpdaterProcess.LogProcessStartInfo(); assemblyUpdaterProcess.Start(); assemblyUpdaterProcess.WaitForExit(); stdOut = assemblyUpdaterProcess.GetStandardOutputAsString(); stdErr = string.Join("\r\n", assemblyUpdaterProcess.GetErrorOutput()); return(assemblyUpdaterProcess.ExitCode); }
private static string GetSdkRoot() { return(Path.Combine(NetCoreProgram.GetNetCoreRoot(), "Sdk")); }