コード例 #1
0
		/// <summary>
		/// UBT startup order is fairly fragile, and relies on globals that may or may not be safe to use yet.
		/// This function is for super early startup stuff that should not access Configuration classes (anything loaded by XmlConfg).
		/// This should be very minimal startup code.
		/// </summary>
		/// <param name="Arguments">Cmdline arguments</param>
		private static void DoStartupStuffThatCannotAccessConfigurationClasses(string[] Arguments)
		{
			// Helpers used for stats tracking.
			StartTime = DateTime.UtcNow;

			// Do super early log init as a safeguard. We'll re-init with proper config options later.
			PreInitLogging();

			// ensure we can resolve any external assemblies that are not in the same folder as our assembly.
			AssemblyUtils.InstallAssemblyResolver(Path.GetDirectoryName(Assembly.GetEntryAssembly().GetOriginalLocation()));

			// Copy off the arguments to allow checking for command-line arguments elsewhere
			CmdLine = new List<string>(Arguments);

			// Grab the environment.
			InitialEnvironment = Environment.GetEnvironmentVariables();
			if (InitialEnvironment.Count < 1)
			{
				throw new BuildException("Environment could not be read");
			}

			// Change the working directory to be the Engine/Source folder. We are likely running from Engine/Binaries/DotNET
			// This is critical to be done early so any code that relies on the current directory being Engine/Source will work.
			// UEBuildConfiguration.PostReset is susceptible to this, so we must do this before configs are loaded.
			string EngineSourceDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().GetOriginalLocation()), "..", "..", "..", "Engine", "Source");

			//@todo.Rocket: This is a workaround for recompiling game code in editor
			// The working directory when launching is *not* what we would expect
			if (Directory.Exists(EngineSourceDirectory) == false)
			{
				// We are assuming UBT always runs from <>/Engine/Binaries/DotNET/...
				EngineSourceDirectory = Assembly.GetExecutingAssembly().GetOriginalLocation();
				EngineSourceDirectory = EngineSourceDirectory.Replace("\\", "/");
				Int32 EngineIdx = EngineSourceDirectory.IndexOf("/Engine/Binaries/DotNET/", StringComparison.InvariantCultureIgnoreCase);
				if (EngineIdx != 0)
				{
					EngineSourceDirectory = Path.Combine(EngineSourceDirectory.Substring(0, EngineIdx), "Engine", "Source");
				}
			}
			if (Directory.Exists(EngineSourceDirectory)) // only set the directory if it exists, this should only happen if we are launching the editor from an artist sync
			{
				Directory.SetCurrentDirectory(EngineSourceDirectory);
			}
		}