Пример #1
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;

            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());
            }

            if (options.ShowProjectOutputs)
            {
                Console.WriteLine("Showing project outputs...");
                ShowProjectOutputs();
            }

            if (options.BuildAll)
            {
                BuildAll();
            }
            else
            {
                if (options.BuildSolutionConfiguration != null)
                {
                    BuildSolutionConfiguration(options.BuildSolutionConfiguration);
                }
                else
                {
                    Console.WriteLine("ERROR: neither BuildAll or BuildSolutionConfiguration was specified");
                    returnValue = 1;
                }
            }

            Console.WriteLine("Closing Solution...");
            CloseSolution();

            Console.WriteLine("Closing Visual Studio...");
            CloseVS();

            return(returnValue);
        }