Files
UnrealEngineUWP/Engine/Source/Programs/AutomationToolLauncher/Launcher.cs
Joakim Lindqvist f90e40ffb0 UAT can now build as a netcore application.
Added a NET_CORE define to allow us to have changes side by side.
The AWS S3 changes are required due to us requiring to upgrade the S3 assembly version to get net core support (which made all methods async).
The ACL checks for files are not available in the system libraries of net core, as such the api is a bit different.

AutomationToolLauncher now just spawns a subprocess when used in netcore, as netcore does not support custom AppDomains and shadow copying. We will generally need to revisit this for netcore as this whole feature of building the source for UAT in UAT is not really possible.

To enable this set environment variable "UE_USE_DOTNET=1", note that with netcore all applications change their output path so this will likely break a bit of tooling when enabled.

#rb ben.marsh

[CL 14572339 by Joakim Lindqvist in ue5-main branch]
2020-10-26 06:08:59 -04:00

102 lines
2.7 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Reflection;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Dynamic;
namespace AutomationToolLauncher
{
class Launcher
{
static int Main(string[] Arguments)
{
// net core does not support shadow copying so we just have to run the executable
#if !NET_CORE
if (Arguments.Contains("-compile", StringComparer.OrdinalIgnoreCase))
{
return RunInAppDomain(Arguments);
}
#endif
return Run(Arguments);
}
#if !NET_CORE
static int RunInAppDomain(string[] Arguments)
{
// Create application domain setup information.
AppDomainSetup Domaininfo = new AppDomainSetup();
Domaininfo.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Domaininfo.ShadowCopyFiles = "true";
// Create the application domain.
AppDomain Domain = AppDomain.CreateDomain("AutomationTool", AppDomain.CurrentDomain.Evidence, Domaininfo);
// Execute assembly and pass through command line
string UATExecutable = Path.Combine(Domaininfo.ApplicationBase, "AutomationTool.exe");
// Default exit code in case UAT does not even start, otherwise we always return UAT's exit code.
int ExitCode = 193;
try
{
ExitCode = Domain.ExecuteAssembly(UATExecutable, Arguments);
// Unload the application domain.
AppDomain.Unload(Domain);
}
catch (Exception Ex)
{
Console.WriteLine(Ex.Message);
Console.WriteLine(Ex.StackTrace);
// We want to terminate the launcher process regardless of any crash dialogs, threads, etc
Environment.Exit(ExitCode);
}
return ExitCode;
}
#endif
static int Run(string[] Arguments)
{
string ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
#if NET_CORE
string UATExecutable = Path.Combine(ApplicationBase, "..\\AutomationTool", "AutomationTool.exe");
#else
string UATExecutable = Path.Combine(ApplicationBase, "AutomationTool.exe");
#endif
if (!File.Exists(UATExecutable))
{
Console.WriteLine(string.Format("AutomationTool does not exist at: {0}", UATExecutable));
return -1;
}
try
{
#if NET_CORE
ProcessStartInfo StartInfo = new ProcessStartInfo(UATExecutable);
foreach (string s in Arguments)
{
StartInfo.ArgumentList.Add(s);
}
Process uatProcess = Process.Start(StartInfo);
uatProcess.WaitForExit();
Environment.Exit(uatProcess.ExitCode);
#else
Assembly UAT = Assembly.LoadFile(UATExecutable);
Environment.Exit((int) UAT.EntryPoint.Invoke(null, new object[] { Arguments }));
#endif
}
catch (Exception Ex)
{
Console.WriteLine(Ex.Message);
Console.WriteLine(Ex.StackTrace);
}
return -1;
}
}
}