public static string Unpack(this TempDirectory tempDirectory, ProcessRuntime runtime)
        {
            var name = runtime switch
            {
                ProcessRuntime.Net461 => "net4.6.1.zip",
                ProcessRuntime.Net48 => "net4.8.zip",
                ProcessRuntime.NetCore31 => "netcoreapp3.1.zip",
                ProcessRuntime.Net50 => "net5.0.zip",
                _ => throw new ArgumentException($"Runtime is not supported: {runtime}"),
            };
            var zipBytes = ResourcesUtilities.ReadFileAsBytes(name);

            var zipPath = Path.Combine(tempDirectory.Folder, name);

            File.WriteAllBytes(zipPath, zipBytes);

            try
            {
                ZipFile.ExtractToDirectory(zipPath, tempDirectory.Folder);
            }
            finally
            {
                File.Delete(zipPath);
            }

            return(Path.Combine(tempDirectory.Folder, ExeName));
        }
Пример #2
0
 /// <summary>
 /// Save Runtime Process
 /// </summary>
 /// <param name="process"></param>
 public void SaveRuntimeProcess(ProcessRuntime process)
 {
     using (var ctx = new ProcessDbContext())
     {
         var persistedProcess = ctx.Process.Find(process.Id);
         if (persistedProcess == null)
         {
             var processDefinitionPersistence =
                 ctx.ProcessDefinition.SingleOrDefault(d => d.Id == Guid.NewGuid() && d.Md5 == "123");
         }
     }
 }
Пример #3
0
    protected static ProcessStartInfo CreateOSDependentStartInfo(Platform platform, ProcessRuntime processRuntime, string processPath,
                                                                 string processArguments, string unityEditorDataDir)
    {
        ProcessStartInfo startInfo;

        if (platform == Platform.Windows)
        {
            startInfo = new ProcessStartInfo(processPath, processArguments);
        }
        else
        {
            string runtimePath;
            switch (processRuntime)
            {
            case ProcessRuntime.CLR40:
                if (File.Exists("/Library/Frameworks/Mono.framework/Commands/mono"))
                {
                    runtimePath = "/Library/Frameworks/Mono.framework/Commands/mono";
                }
                else
                {
                    runtimePath = Path.Combine(unityEditorDataDir, "MonoBleedingEdge/bin/mono");
                }
                break;

            case ProcessRuntime.CLR20:
                runtimePath = Path.Combine(unityEditorDataDir, @"Mono/bin/mono");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(processRuntime), processRuntime, null);
            }

            startInfo = new ProcessStartInfo(runtimePath, $"\"{processPath}\" {processArguments}");

            if (processRuntime != ProcessRuntime.CLR20)
            {
                // Since we already are running under old mono runtime, we need to remove
                // these variables before launching the different version of the runtime.
                var vars = startInfo.EnvironmentVariables;
                vars.Remove("MONO_PATH");
                vars.Remove("MONO_CFG_DIR");
            }
        }

        startInfo.RedirectStandardError  = true;
        startInfo.RedirectStandardOutput = true;
        startInfo.UseShellExecute        = false;

        return(startInfo);
    }
	protected static ProcessStartInfo CreateOSDependentStartInfo(Platform platform, ProcessRuntime processRuntime, string processPath, string processArguments,
																 string unityEditorDataDir)
	{
		ProcessStartInfo startInfo;

		if (platform == Platform.Windows)
		{
			switch (processRuntime)
			{
				case ProcessRuntime.CLR20:
					var runtimePath = Path.Combine(unityEditorDataDir, @"Mono/bin/mono.exe");
					startInfo = new ProcessStartInfo(runtimePath, $"\"{processPath}\" {processArguments}");
					break;

				case ProcessRuntime.CLR40:
					startInfo = new ProcessStartInfo(processPath, processArguments);
					break;

				default:
					throw new ArgumentOutOfRangeException(nameof(processRuntime), processRuntime, null);
			}
		}
		else
		{
			string runtimePath;
			switch (processRuntime)
			{
				case ProcessRuntime.CLR40:
					if (File.Exists("/usr/local/bin/mono"))
					{
						runtimePath = "/usr/local/bin/mono";
					}
					else
					{
						runtimePath = Path.Combine(unityEditorDataDir, "MonoBleedingEdge/bin/mono");
					}
					break;

				case ProcessRuntime.CLR20:
					runtimePath = Path.Combine(unityEditorDataDir, @"Mono/bin/mono");
					break;

				default:
					throw new ArgumentOutOfRangeException(nameof(processRuntime), processRuntime, null);
			}

			startInfo = new ProcessStartInfo(runtimePath, $"\"{processPath}\" {processArguments}");

			if (processRuntime != ProcessRuntime.CLR20)
			{
				// Since we already are running under old mono runtime, we need to remove
				// these variables before launching the different version of the runtime.
				var vars = startInfo.EnvironmentVariables;
				vars.Remove("MONO_PATH");
				vars.Remove("MONO_CFG_DIR");
			}
		}

		startInfo.RedirectStandardError = true;
		startInfo.RedirectStandardOutput = true;
		startInfo.UseShellExecute = false;

		return startInfo;
	}