protected IAppInstall InstallStagedBuild(UnrealAppConfig AppConfig, StagedBuild InBuild)
        {
            bool SkipDeploy = Globals.Params.ParseParam("SkipDeploy");

            string BuildPath = InBuild.BuildPath;

            if (CanRunFromPath(BuildPath) == false)
            {
                string SubDir   = string.IsNullOrEmpty(AppConfig.Sandbox) ? AppConfig.ProjectName : AppConfig.Sandbox;
                string DestPath = Path.Combine(this.TempDir, SubDir, AppConfig.ProcessType.ToString());

                if (!SkipDeploy)
                {
                    StagedBuild.InstallBuildParallel(AppConfig, InBuild, BuildPath, DestPath, ToString());
                }
                else
                {
                    Log.Info("Skipping install of {0} (-skipdeploy)", BuildPath);
                }

                Utils.SystemHelpers.MarkDirectoryForCleanup(DestPath);

                BuildPath = DestPath;
            }

            WindowsAppInstall WinApp = new WindowsAppInstall(AppConfig.Name, AppConfig.ProjectName, this);

            WinApp.RunOptions = RunOptions;

            // Set commandline replace any InstallPath arguments with the path we use
            WinApp.CommandArguments = Regex.Replace(AppConfig.CommandLine, @"\$\(InstallPath\)", BuildPath, RegexOptions.IgnoreCase);

            if (string.IsNullOrEmpty(UserDir) == false)
            {
                WinApp.CommandArguments += string.Format(" -userdir=\"{0}\"", UserDir);
                WinApp.ArtifactPath      = Path.Combine(UserDir, @"Saved");

                Utils.SystemHelpers.MarkDirectoryForCleanup(UserDir);
            }
            else
            {
                // e.g d:\Unreal\GameName\Saved
                WinApp.ArtifactPath = Path.Combine(BuildPath, AppConfig.ProjectName, @"Saved");
            }

            // clear artifact path
            if (Directory.Exists(WinApp.ArtifactPath))
            {
                try
                {
                    Directory.Delete(WinApp.ArtifactPath, true);
                }
                catch (Exception Ex)
                {
                    Log.Warning("Failed to delete {0}. {1}", WinApp.ArtifactPath, Ex.Message);
                }
            }

            if (LocalDirectoryMappings.Count == 0)
            {
                PopulateDirectoryMappings(Path.Combine(BuildPath, AppConfig.ProjectName), UserDir);
            }

            if (AppConfig.FilesToCopy != null)
            {
                foreach (UnrealFileToCopy FileToCopy in AppConfig.FilesToCopy)
                {
                    string PathToCopyTo = Path.Combine(LocalDirectoryMappings[FileToCopy.TargetBaseDirectory], FileToCopy.TargetRelativeLocation);
                    if (File.Exists(FileToCopy.SourceFileLocation))
                    {
                        FileInfo SrcInfo = new FileInfo(FileToCopy.SourceFileLocation);
                        SrcInfo.IsReadOnly = false;
                        string DirectoryToCopyTo = Path.GetDirectoryName(PathToCopyTo);
                        if (!Directory.Exists(DirectoryToCopyTo))
                        {
                            Directory.CreateDirectory(DirectoryToCopyTo);
                        }
                        if (File.Exists(PathToCopyTo))
                        {
                            FileInfo ExistingFile = new FileInfo(PathToCopyTo);
                            ExistingFile.IsReadOnly = false;
                        }
                        SrcInfo.CopyTo(PathToCopyTo, true);
                        Log.Info("Copying {0} to {1}", FileToCopy.SourceFileLocation, PathToCopyTo);
                    }
                    else
                    {
                        Log.Warning("File to copy {0} not found", FileToCopy);
                    }
                }
            }

            if (Path.IsPathRooted(InBuild.ExecutablePath))
            {
                WinApp.ExecutablePath = InBuild.ExecutablePath;
            }
            else
            {
                // TODO - this check should be at a higher level....
                string BinaryPath = Path.Combine(BuildPath, InBuild.ExecutablePath);

                // check for a local newer executable
                if (Globals.Params.ParseParam("dev") && AppConfig.ProcessType.UsesEditor() == false)
                {
                    string LocalBinary = Path.Combine(Environment.CurrentDirectory, InBuild.ExecutablePath);

                    bool LocalFileExists = File.Exists(LocalBinary);
                    bool LocalFileNewer  = LocalFileExists && File.GetLastWriteTime(LocalBinary) > File.GetLastWriteTime(BinaryPath);

                    Log.Verbose("Checking for newer binary at {0}", LocalBinary);
                    Log.Verbose("LocalFile exists: {0}. Newer: {1}", LocalFileExists, LocalFileNewer);

                    if (LocalFileExists && LocalFileNewer)
                    {
                        // need to -basedir to have our exe load content from the path
                        WinApp.CommandArguments += string.Format(" -basedir={0}", Path.GetDirectoryName(BinaryPath));

                        BinaryPath = LocalBinary;
                    }
                }

                WinApp.ExecutablePath = BinaryPath;
            }

            return(WinApp);
        }
        protected IAppInstall InstallStagedBuild(UnrealAppConfig AppConfig, StagedBuild InBuild)
        {
            bool SkipDeploy = Globals.Params.ParseParam("SkipDeploy");

            string BuildPath = InBuild.BuildPath;

            // Must be on our volume to run
            string BuildVolume = GetVolumeName(BuildPath);
            string LocalRoot   = GetVolumeName(Environment.CurrentDirectory);

            if (BuildVolume.Equals(LocalRoot, StringComparison.OrdinalIgnoreCase) == false)
            {
                string SubDir   = string.IsNullOrEmpty(AppConfig.Sandbox) ? AppConfig.ProjectName : AppConfig.Sandbox;
                string DestPath = Path.Combine(this.TempDir, SubDir, AppConfig.ProcessType.ToString());

                if (!SkipDeploy)
                {
                    StagedBuild.InstallBuildParallel(AppConfig, InBuild, BuildPath, DestPath, ToString());
                }
                else
                {
                    Log.Info("Skipping install of {0} (-skipdeploy)", BuildPath);
                }

                Utils.SystemHelpers.MarkDirectoryForCleanup(DestPath);

                BuildPath = DestPath;
            }

            MacAppInstall MacApp = new MacAppInstall(AppConfig.Name, this);

            MacApp.LocalPath        = BuildPath;
            MacApp.WorkingDirectory = MacApp.LocalPath;
            MacApp.RunOptions       = RunOptions;

            // Set commandline replace any InstallPath arguments with the path we use
            MacApp.CommandArguments = Regex.Replace(AppConfig.CommandLine, @"\$\(InstallPath\)", BuildPath, RegexOptions.IgnoreCase);

            // Mac always forces this to stop logs and other artifacts going to different places
            // Mac always forces this to stop logs and other artifacts going to different places
            MacApp.CommandArguments += string.Format(" -userdir=\"{0}\"", UserDir);
            MacApp.ArtifactPath      = Path.Combine(UserDir, @"Saved");

            // temp - Mac doesn't support -userdir?
            //MacApp.ArtifactPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Library/Logs", AppConfig.ProjectName);

            // clear artifact path
            if (Directory.Exists(MacApp.ArtifactPath))
            {
                try
                {
                    Directory.Delete(MacApp.ArtifactPath, true);
                }
                catch (Exception Ex)
                {
                    Log.Warning("Failed to delete {0}. {1}", MacApp.ArtifactPath, Ex.Message);
                }
            }

            // For Mac turn Foo.app into Foo/Content/MacOS/Foo
            string AppPath  = Path.GetDirectoryName(InBuild.ExecutablePath);
            string FileName = Path.GetFileNameWithoutExtension(InBuild.ExecutablePath);

            MacApp.ExecutablePath = Path.Combine(InBuild.ExecutablePath, "Contents", "MacOS", FileName);

            if (!Path.IsPathRooted(MacApp.ExecutablePath))
            {
                // TODO - this check should be at a higher level....
                string BinaryPath = Path.Combine(BuildPath, MacApp.ExecutablePath);

                // check for a local newer executable
                if (Globals.Params.ParseParam("dev") && AppConfig.ProcessType.UsesEditor() == false)
                {
                    string LocalBinary = Path.Combine(Environment.CurrentDirectory, MacApp.ExecutablePath);

                    bool LocalFileExists = File.Exists(LocalBinary);
                    bool LocalFileNewer  = LocalFileExists && File.GetLastWriteTime(LocalBinary) > File.GetLastWriteTime(BinaryPath);

                    Log.Verbose("Checking for newer binary at {0}", LocalBinary);
                    Log.Verbose("LocalFile exists: {0}. Newer: {1}", LocalFileExists, LocalFileNewer);

                    if (LocalFileExists && LocalFileNewer)
                    {
                        string LocalAppPath = Path.Combine(Environment.CurrentDirectory, InBuild.ExecutablePath);

                        // need to -basedir to have our exe load content from the path
                        MacApp.CommandArguments += string.Format(" -basedir={0}", Path.GetDirectoryName(LocalAppPath));

                        BinaryPath = LocalBinary;
                    }
                }

                MacApp.ExecutablePath = BinaryPath;
            }

            return(MacApp);
        }