Пример #1
0
        public override void ExecuteBuild()
        {
            var    gameBuildVersion   = ParseOptionalStringParam("GameVersionOverride");
            string maybeGameDirectory = null;

            if (gameBuildVersion == null)
            {
                var gameDir          = ParseRequiredStringParam("GameDir");
                var bootstrapExePath = Path.Combine(gameDir, "FactoryGame.exe");
                if (!FileExists(bootstrapExePath))
                {
                    throw new AutomationException("Provided -GameDir is invalid: '{0}'", gameDir);
                }
                gameBuildVersion   = RetrieveBuildIdFromGame(gameDir);
                maybeGameDirectory = gameDir;
            }

            LogInformation("Game Build Id: {0}", gameBuildVersion);

            var factoryGameParams = new FactoryGameParams
            {
                GameBuildId         = gameBuildVersion,
                GameDirectory       = maybeGameDirectory,
                StartGame           = ParseParam("LaunchGame"),
                CopyToGameDirectory = ParseParam("CopyToGameDir")
            };

            if (factoryGameParams.StartGame)
            {
                factoryGameParams.LaunchGameURL = GetGameLaunchURL(this);
            }

            var projectParams = GetParams(this);

            Project.Cook(projectParams);
            var deploymentContexts = CreateDeploymentContexts(projectParams);

            RemapCookedPluginsContentPaths(projectParams, deploymentContexts);

            try
            {
                CopyBuildToStagingDirectory(projectParams, deploymentContexts);
                PackagePluginProject(deploymentContexts, gameBuildVersion);
                ArchivePluginProject(projectParams, deploymentContexts);
                DeployPluginProject(projectParams, deploymentContexts, factoryGameParams);
            }
            finally
            {
                //Clean staging directories because they confuse cooking commandlet and UBT
                CleanStagingDirectories(deploymentContexts);
            }

            LaunchGame(this);
        }
        private static void DeployPluginProject(ProjectParams projectParams,
                                                IEnumerable <DeploymentContext> deploymentContexts, FactoryGameParams factoryGameParams)
        {
            foreach (var deploymentContext in deploymentContexts)
            {
                if (factoryGameParams.CopyToGameDirectory &&
                    deploymentContext.FinalCookPlatform == "WindowsNoEditor")
                {
                    var stageRootDirectory   = deploymentContext.StageDirectory;
                    var relativePluginPath   = GetPluginPathRelativeToStageRoot(projectParams, deploymentContext);
                    var stagePluginDirectory = Path.Combine(stageRootDirectory.ToString(), relativePluginPath);

                    if (factoryGameParams.GameDirectory == null)
                    {
                        throw new AutomationException(
                                  "-CopyToGameDirectory was specified, but no game directory path has been provided");
                    }

                    CopyPluginToTheGameDir(factoryGameParams.GameDirectory, projectParams.RawProjectPath,
                                           projectParams.DLCFile, stagePluginDirectory);
                }
            }

            if (factoryGameParams.StartGame)
            {
                System.Diagnostics.Process.Start(factoryGameParams.LaunchGameURL);
            }
        }