public override void CompileCSharpProject(CSharpEnvironment CompileEnvironment, string ProjectFileName, string DestinationFile) { // Initialize environment variables required for spawned tools. var EnvVars = VCEnvironment.SetEnvironment(CompileEnvironment.EnvironmentTargetPlatform); var BuildProjectAction = new Action(ActionType.BuildProject); // Specify the source file (prerequisite) for the action var ProjectFileItem = FileItem.GetExistingItemByPath(ProjectFileName); if (ProjectFileItem == null) { throw new BuildException("Expected C# project file {0} to exist.", ProjectFileName); } // Add the project and the files contained to the prerequisites. BuildProjectAction.PrerequisiteItems.Add(ProjectFileItem); var ProjectFile = new VCSharpProjectFile(Utils.MakePathRelativeTo(ProjectFileName, ProjectFileGenerator.MasterProjectRelativePath)); var ProjectPreReqs = ProjectFile.GetCSharpDependencies(); var ProjectFolder = Path.GetDirectoryName(ProjectFileName); foreach (string ProjectPreReqRelativePath in ProjectPreReqs) { string ProjectPreReqAbsolutePath = Path.Combine(ProjectFolder, ProjectPreReqRelativePath); var ProjectPreReqFileItem = FileItem.GetExistingItemByPath(ProjectPreReqAbsolutePath); if (ProjectPreReqFileItem == null) { throw new BuildException("Expected C# dependency {0} to exist.", ProjectPreReqAbsolutePath); } BuildProjectAction.PrerequisiteItems.Add(ProjectPreReqFileItem); } // We might be able to distribute this safely, but it doesn't take any time. BuildProjectAction.bCanExecuteRemotely = false; // Setup execution via MSBuild. BuildProjectAction.WorkingDirectory = Path.GetFullPath("."); BuildProjectAction.StatusDescription = Path.GetFileName(ProjectFileName); BuildProjectAction.CommandPath = EnvVars.MSBuildPath; if (CompileEnvironment.TargetConfiguration == CSharpTargetConfiguration.Debug) { BuildProjectAction.CommandArguments = " /target:rebuild /property:Configuration=Debug"; } else { BuildProjectAction.CommandArguments = " /target:rebuild /property:Configuration=Development"; } // Be less verbose BuildProjectAction.CommandArguments += " /nologo /verbosity:minimal"; // Add project BuildProjectAction.CommandArguments += String.Format(" \"{0}\"", ProjectFileItem.AbsolutePath); // Specify the output files. string PDBFilePath = Path.Combine(Path.GetDirectoryName(DestinationFile), Path.GetFileNameWithoutExtension(DestinationFile) + ".pdb"); FileItem PDBFile = FileItem.GetItemByPath(PDBFilePath); BuildProjectAction.ProducedItems.Add(FileItem.GetItemByPath(DestinationFile)); BuildProjectAction.ProducedItems.Add(PDBFile); }
/// <summary> /// Adds a C# project to the master project /// </summary> /// <param name="ProjectName">Name of project file to add</param> /// <returns>ProjectFile if the operation was successful, otherwise null.</returns> private VCSharpProjectFile AddSimpleCSharpProject(string ProjectName, bool bShouldBuildForAllSolutionTargets = false, bool bForceDevelopmentConfiguration = false) { VCSharpProjectFile Project = null; var ProjectFileName = Path.Combine(EngineRelativePath, "Source", "Programs", ProjectName, Path.GetFileName(ProjectName) + ".csproj"); FileInfo Info = new FileInfo(ProjectFileName); if (Info.Exists) { var FileNameRelativeToMasterProject = Utils.MakePathRelativeTo(ProjectFileName, MasterProjectRelativePath); Project = new VCSharpProjectFile(FileNameRelativeToMasterProject); Project.ShouldBuildForAllSolutionTargets = bShouldBuildForAllSolutionTargets; AddExistingProjectFile(Project, bForceDevelopmentConfiguration: bForceDevelopmentConfiguration); } else { throw new BuildException(ProjectFileName + " doesn't exist!"); } return Project; }
/// <summary> /// Adds STBuildTool to the master project /// </summary> private void AddSTBuildToolProject(MasterProjectFolder ProgramsFolder) { var ProjectFileName = Utils.MakePathRelativeTo(Path.Combine(Path.Combine(EngineRelativePath, "Source"), "Programs", "STBuildTool", "STBuildTool.csproj"), MasterProjectRelativePath); var STBuildToolProject = new VCSharpProjectFile(ProjectFileName); STBuildToolProject.ShouldBuildForAllSolutionTargets = true; // Store it off as we need it when generating target projects. UBTProject = STBuildToolProject; // Add the project AddExistingProjectFile(STBuildToolProject, bNeedsAllPlatformAndConfigurations: true, bForceDevelopmentConfiguration: true); // Put this in a solution folder ProgramsFolder.ChildProjects.Add(STBuildToolProject); }
/// <summary> /// Adds all .automation.csproj files to the solution. /// </summary> void AddAutomationModules(MasterProjectFolder ProgramsFolder) { var Folder = ProgramsFolder.AddSubFolder("Automation"); var AllGameFolders = STBuildTarget.DiscoverAllGameFolders(); var BuildFolders = new List<string>(AllGameFolders.Count); foreach (var GameFolder in AllGameFolders) { var GameBuildFolder = Path.Combine(GameFolder, "Build"); if (Directory.Exists(GameBuildFolder)) { BuildFolders.Add(GameBuildFolder); } } // Find all the automation modules .csproj files to add var ModuleFiles = RulesCompiler.FindAllRulesSourceFiles(RulesCompiler.RulesFileType.AutomationModule, BuildFolders); foreach (var ProjectFile in ModuleFiles) { FileInfo Info = new FileInfo(Path.Combine(ProjectFile)); if (Info.Exists) { var RelativeFileName = Utils.MakePathRelativeTo(ProjectFile, MasterProjectRelativePath); var Project = new VCSharpProjectFile(RelativeFileName); Project.ShouldBuildForAllSolutionTargets = true; AddExistingProjectFile(Project, bForceDevelopmentConfiguration: true); Folder.ChildProjects.Add(Project); } } }