Esempio n. 1
0
        private void MenuItemCallback_Build(object sender, EventArgs e)
        {
            if (_previousRunner != null && _previousRunner.IsRunning)
                return;

            DTE dte = (DTE)this.GetService(typeof(SDTE));
            dte.ExecuteCommand("File.SaveAll", String.Empty);

            var buildwnd = GetOutputPane(VSConstants.BuildOutput, "Build");
            // Update settings...
            Singleton<DeployServiceProvider>.Instance.UpdateSettings(GetFolders());
            Singleton<DeployServiceProvider>.Instance.BuildWindow = buildwnd;
            buildwnd.Activate();

            Project activeProj = GetActiveProject();
            if (activeProj != null)
            {
                try
                {
                    MSBuildRunner runner = new MSBuildRunner(this, GetMSBuildPath(), GetActiveProject().Name, activeProj.FullName, buildwnd);
                    runner.Configuration = activeProj.ConfigurationManager.ActiveConfiguration.ConfigurationName;
                    runner.AutoDeploy = GetAutoDeploy();
                    runner.DisableCA = GetDisableCA();
                    runner.BuildProject = activeProj;
                    runner.Start();
                }
                catch (Exception ee)
                {
                    buildwnd.OutputString(string.Format(@"Build failed due to exception: {0}", ee.Message));
                }
            }
            else
            {
                // Solution build....
                var sln = GetSolution();
                if (sln.Projects.Count < 1)
                {
                    buildwnd.OutputString(@"Empty solution, bypass!!");
                    return;
                }
                try
                {
                    MSBuildRunner runner = new MSBuildRunner(this, GetMSBuildPath(), "Solution", sln.FullName, buildwnd);
                    runner.Configuration = sln.Projects.Item(1).ConfigurationManager.ActiveConfiguration.ConfigurationName;
                    runner.AutoDeploy = GetAutoDeploy();
                    runner.DisableCA = GetDisableCA();
                    runner.BuildProject = null;
                    runner.BuildSolution = sln;
                    runner.Start();
                }
                catch (Exception ee)
                {
                    buildwnd.OutputString(string.Format(@"Build failed due to exception: {0}", ee.Message));
                }
            }
        }
        public void StartBuildSolution(Solution buildSolution, string msbuildPath, bool autoDeploy, bool disableCA, bool disableOptimize)
        {
            if (IsRunning)
            {
                OutputPane.OutputStringThreadSafe(@"Builder is busy now...\r\n");
                return;
            }
            __currentrunner = new MSBuildRunner(this.serviceProvider, msbuildPath, "Solution", buildSolution.FullName, OutputPane);
            __currentrunner.Configuration = buildSolution.Projects.Item(1).ConfigurationManager.ActiveConfiguration.ConfigurationName;
            __currentrunner.AutoDeploy = autoDeploy;
            __currentrunner.DisableCA = disableCA;
            __currentrunner.DisableOptimize = disableOptimize;
            __currentrunner.BuildProject = null;
            __currentrunner.BuildSolution = buildSolution;

            __currentrunner.OnBuildError += new MSBuildRunner.BuildErrorEventHandler(__currentrunner_OnBuildError);
            __currentrunner.OnBuildInternalError += new MSBuildRunner.BuildInternalEventHandler(__currentrunner_OnBuildInternalError);
            __currentrunner.OnBuildWarning += new MSBuildRunner.BuildWarningEventHandler(__currentrunner_OnBuildWarning);
            __currentrunner.OnBuildFinished += new MSBuildRunner.BuildFinishedEventHandler(__currentrunner_OnBuildFinished);
            __currentrunner.OnBuildStart += new MSBuildRunner.BuildStartEventHandler(__currentrunner_OnBuildStart);

            __currentrunner.Start();
        }