/// <summary> /// Build solution as specified in options /// </summary> /// <param name="options">Build configuration options</param> /// <returns></returns> public int Run(VsBuilderOptions options) { this.options = options; this.Results = new VsBuilderResults(); Console.WriteLine("Opening Visual Studio 2008..."); OpenVS(); dte.SuppressUI = !options.Debug; dte.UserControl = options.Debug; if (!File.Exists(options.Solution)) { Console.WriteLine("Solution file not found"); return(1); } Console.WriteLine("Opening Solution..."); if (!OpenSolution(options.Solution)) { Console.WriteLine("Solution could not be opened"); return(2); } Console.WriteLine("Solution.Count = " + sln.Count); Console.WriteLine("Projects Names..."); foreach (Project project in dte.Solution.Projects) { Console.WriteLine("Project: " + project.Name); } if (options.ShowProjectContexts) { Console.WriteLine("Showing project contexts..."); Console.WriteLine(GetProjectContexts()); } ShowProjectOutputs(); if (options.BuildAll) { BuildAll(); } else { if (options.BuildSolutionConfiguration != null) { BuildSolutionConfiguration(options.BuildSolutionConfiguration); } } Console.WriteLine("Closing Solution..."); CloseSolution(); Console.WriteLine("Closing Visual Studio..."); CloseVS(); return(0); }
/// <summary> /// Build solution as specified in options /// </summary> /// <param name="options">Build configuration options</param> /// <returns></returns> public int Run(VsBuilderOptions options) { int returnValue = 0; this.options = options; this.Results = new VsBuilderResults(); Console.WriteLine("Opening Visual Studio 2008..."); OpenVS(); dte.SuppressUI = !options.Debug; dte.UserControl = options.Debug; // Resolve the solution absolute filepath string absSolutionFilePath = ResolveSolutionName(options.Solution); if (!File.Exists(absSolutionFilePath)) { Console.WriteLine("Solution file not found"); return(1); } Console.WriteLine("Opening Solution..."); if (!OpenSolution(absSolutionFilePath)) { Console.WriteLine("Solution could not be opened"); return(2); } #if DEBUG Console.WriteLine("Solution.Count = " + sln.Count); Console.WriteLine("Projects Names..."); foreach (Project project in dte.Solution.Projects) { Console.WriteLine("Project: " + project.Name); } #endif if (options.ShowProjectContexts) { Console.WriteLine("Showing project contexts..."); Console.WriteLine(GetProjectContexts()); } if (options.ShowProjectOutputs) { Console.WriteLine("Showing project outputs..."); ShowProjectOutputs(); } if (options.BuildAll) { BuildAll(); } else { if (options.BuildSolutionConfiguration != null) { if (options.BuildProject != null) { string projUniqueName = GetProjectUniqueName(options.BuildProject); if (string.IsNullOrEmpty(projUniqueName)) { Console.WriteLine("ERROR: The specified project was not found in the solution."); returnValue = 1; } BuildProject(options.BuildSolutionConfiguration, projUniqueName); } else { BuildSolutionConfiguration(options.BuildSolutionConfiguration); } } else { Console.WriteLine("ERROR: neither BuildAll or BuildSolutionConfiguration was specified"); returnValue = 1; } } if (options.ShowBuild) { string buildOutput = GetOutputWindowText("Build"); if (!string.IsNullOrEmpty(buildOutput)) { Console.WriteLine("Build Output:"); string[] buildLines = buildOutput.Split('\n'); foreach (string line in buildLines) { Console.WriteLine(line); } } else { Console.WriteLine("Build Output: None"); } } Console.WriteLine("Closing Solution..."); CloseSolution(); Console.WriteLine("Closing Visual Studio..."); CloseVS(); return(returnValue); }