private bool BuildProject(EnvDTE.Project project)
 {
     try
     {
         BuildLogger logger = new BuildLogger(OutputPane);
         logger.Verbosity = LoggerVerbosity;
         BuildingProject  = project;
         if (!Builder.Build(project, new BuildCallback(project, OutputPane, ActiveConfiguration),
                            logger))
         {
             BuildingProject = null;
         }
         return(BuildingProject != null);
     }
     catch (Exception)
     {
         BuildingProject = null;
         return(false);
     }
 }
Exemplo n.º 2
0
 private bool BuildProject(IVsProject project)
 {
     try
     {
         BuildLogger logger = new BuildLogger(OutputPane)
         {
             Verbosity = LoggerVerbosity
         };
         BuildingProject = project;
         var dteproject          = project.GetDTEProject();
         var activeConfiguration = dteproject.ConfigurationManager.ActiveConfiguration;
         if (!Builder.Build(project, new BuildCallback(project, OutputPane, activeConfiguration), logger))
         {
             BuildingProject = null;
         }
         return(BuildingProject != null);
     }
     catch (Exception)
     {
         BuildingProject = null;
         return(false);
     }
 }
Exemplo n.º 3
0
        public bool Build(IVsProject project, BuildCallback buildCallback, BuildLogger buildLogger, string platform, string configuration)
        {
            return(project.WithProject((MSBuildProject msproject) =>
            {
                //
                // We need to set this before we acquire the build resources otherwise Msbuild
                // will not see the changes.
                //
                bool onlyLogCriticalEvents = msproject.ProjectCollection.OnlyLogCriticalEvents;
                msproject.ProjectCollection.Loggers.Add(buildLogger);
                msproject.ProjectCollection.OnlyLogCriticalEvents = false;

                uint cookie;
                int err = BuildManagerAccessor.AcquireBuildResources(VSBUILDMANAGERRESOURCE.VSBUILDMANAGERRESOURCE_DESIGNTIME |
                                                                     VSBUILDMANAGERRESOURCE.VSBUILDMANAGERRESOURCE_UITHREAD, out cookie);

                if (err != VSConstants.E_PENDING && err != VSConstants.S_OK)
                {
                    ErrorHandler.ThrowOnFailure(err);
                }

                if (err == VSConstants.E_PENDING)
                {
                    msproject.ProjectCollection.Loggers.Remove(buildLogger);
                    msproject.ProjectCollection.OnlyLogCriticalEvents = onlyLogCriticalEvents;

                    Dispatcher = Dispatcher.CurrentDispatcher;
                    BuildAvailableEvent = new ManualResetEvent(false);
                    BuildAvailableEvent.SafeWaitHandle = new SafeWaitHandle(BuildManagerAccessor.DesignTimeBuildAvailable, false);

                    Thread t = new Thread(() =>
                    {
                        BuildAvailableEvent.WaitOne();
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            Package.Instance.BuildNextProject();
                        }));
                    });
                    t.Start();
                    return false;
                }
                else
                {
                    try
                    {
                        Dictionary <string, string> properties = new Dictionary <string, string>();
                        properties["Platform"] = platform;
                        properties["Configuration"] = configuration;

                        BuildRequestData buildRequest = new BuildRequestData(
                            msproject.FullPath,
                            properties,
                            null,
                            new string[] { "SliceCompile" },
                            msproject.ProjectCollection.HostServices,
                            BuildRequestDataFlags.ProvideProjectStateAfterBuild |
                            BuildRequestDataFlags.IgnoreExistingProjectState |
                            BuildRequestDataFlags.ReplaceExistingProjectInstance);

                        BuildSubmission submission = BuildManager.DefaultBuildManager.PendBuildRequest(buildRequest);
                        ErrorHandler.ThrowOnFailure(BuildManagerAccessor.RegisterLogger(submission.SubmissionId, buildLogger));
                        Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() =>
                        {
                            buildCallback.BeginBuild(platform, configuration);
                        }));
                        submission.ExecuteAsync(s =>
                        {
                            Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() =>
                            {
                                msproject.ProjectCollection.Loggers.Remove(buildLogger);
                                msproject.ProjectCollection.OnlyLogCriticalEvents = onlyLogCriticalEvents;
                                BuildManagerAccessor.ReleaseBuildResources(cookie);
                                s.BuildManager.ResetCaches();
                                BuildManagerAccessor.UnregisterLoggers(s.SubmissionId);
                                buildCallback.EndBuild(s.BuildResult.OverallResult == BuildResultCode.Success);
                            }));
                        }, null);

                        return true;
                    }
                    catch (Exception)
                    {
                        msproject.ProjectCollection.Loggers.Remove(buildLogger);
                        msproject.ProjectCollection.OnlyLogCriticalEvents = onlyLogCriticalEvents;
                        BuildManagerAccessor.ReleaseBuildResources(cookie);
                        throw;
                    }
                }
            }));
        }
Exemplo n.º 4
0
 private bool BuildProject(EnvDTE.Project project)
 {
     try
     {
         BuildLogger logger = new BuildLogger(OutputPane);
         logger.Verbosity = LoggerVerbosity;
         BuildingProject = project;
         if (!Builder.Build(project, new BuildCallback(project, OutputPane, ActiveConfiguration),
                            logger))
         {
             BuildingProject = null;
         }
         return BuildingProject != null;
     }
     catch(Exception)
     {
         BuildingProject = null;
         return false;
     }
 }
Exemplo n.º 5
0
        public bool Build(EnvDTE.Project p, BuildCallback buildCallback, BuildLogger buildLogger)
        {
            p.Save();
            MSBuildProject project = MSBuildUtils.LoadedProject(p.FullName, false);

            //
            // We need to set this before we acquire the build resources otherwise Msbuild
            // will not see the changes.
            //
            bool onlyLogCriticalEvents = project.ProjectCollection.OnlyLogCriticalEvents;
            project.ProjectCollection.Loggers.Add(buildLogger);
            project.ProjectCollection.OnlyLogCriticalEvents = false;

            uint cookie;
            int err = BuildManagerAccessor.AcquireBuildResources(VSBUILDMANAGERRESOURCE.VSBUILDMANAGERRESOURCE_DESIGNTIME |
                                                                 VSBUILDMANAGERRESOURCE.VSBUILDMANAGERRESOURCE_UITHREAD, out cookie);

            if (err != VSConstants.E_PENDING && err != VSConstants.S_OK)
            {
                ErrorHandler.ThrowOnFailure(err);
            }

            if (err == VSConstants.E_PENDING)
            {
                project.ProjectCollection.Loggers.Remove(buildLogger);
                project.ProjectCollection.OnlyLogCriticalEvents = onlyLogCriticalEvents;

                Dispatcher = Dispatcher.CurrentDispatcher;
                BuildAvailableEvent = new System.Threading.ManualResetEvent(false);
                BuildAvailableEvent.SafeWaitHandle = new SafeWaitHandle(BuildManagerAccessor.DesignTimeBuildAvailable, false);

                Thread t = new Thread(() =>
                    {
                        BuildAvailableEvent.WaitOne();
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            Package.Instance.BuildNextProject();
                        }));
                    });
                t.Start();
                return false;
            }
            else
            {
                Package.Instance.FileTracker.Reap(p);
                ProjectUtil.SetupGenerated(p);
                
                try
                {
                    BuildRequestData buildRequest = new BuildRequestData(
                            BuildManager.DefaultBuildManager.GetProjectInstanceForBuild(project),
                            new String[] { "IceBuilder_Compile" },
                            project.ProjectCollection.HostServices,
                            BuildRequestDataFlags.IgnoreExistingProjectState |
                            BuildRequestDataFlags.ReplaceExistingProjectInstance);

                    BuildSubmission submission = BuildManager.DefaultBuildManager.PendBuildRequest(buildRequest);
                    ErrorHandler.ThrowOnFailure(BuildManagerAccessor.RegisterLogger(submission.SubmissionId, buildLogger));
                    buildCallback.BeginBuild();
                    submission.ExecuteAsync((s) =>
                        {
                            Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() =>
                            {
                                project.ProjectCollection.Loggers.Remove(buildLogger);
                                project.ProjectCollection.OnlyLogCriticalEvents = onlyLogCriticalEvents;
                                BuildManagerAccessor.ReleaseBuildResources(cookie);
                                BuildManagerAccessor.UnregisterLoggers(submission.SubmissionId);
                                buildCallback.EndBuild(submission.BuildResult.OverallResult == BuildResultCode.Success);
                            }));
                        }, null);
                    
                    return true;
                }
                catch (Exception)
                {
                    project.ProjectCollection.Loggers.Remove(buildLogger);
                    project.ProjectCollection.OnlyLogCriticalEvents = onlyLogCriticalEvents;
                    BuildManagerAccessor.ReleaseBuildResources(cookie);
                    throw;
                }
            }
        }
Exemplo n.º 6
0
        public bool Build(IVsProject p, BuildCallback buildCallback, BuildLogger buildLogger)
        {
            MSBuildProject project = MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(p), DTEUtil.IsCppProject(p), false);

            //
            // We need to set this before we acquire the build resources otherwise Msbuild
            // will not see the changes.
            //
            bool onlyLogCriticalEvents = project.ProjectCollection.OnlyLogCriticalEvents;

            project.ProjectCollection.Loggers.Add(buildLogger);
            project.ProjectCollection.OnlyLogCriticalEvents = false;

            uint cookie;
            int  err = BuildManagerAccessor.AcquireBuildResources(VSBUILDMANAGERRESOURCE.VSBUILDMANAGERRESOURCE_DESIGNTIME |
                                                                  VSBUILDMANAGERRESOURCE.VSBUILDMANAGERRESOURCE_UITHREAD, out cookie);

            if (err != VSConstants.E_PENDING && err != VSConstants.S_OK)
            {
                ErrorHandler.ThrowOnFailure(err);
            }

            if (err == VSConstants.E_PENDING)
            {
                project.ProjectCollection.Loggers.Remove(buildLogger);
                project.ProjectCollection.OnlyLogCriticalEvents = onlyLogCriticalEvents;

                Dispatcher          = Dispatcher.CurrentDispatcher;
                BuildAvailableEvent = new System.Threading.ManualResetEvent(false);
                BuildAvailableEvent.SafeWaitHandle = new SafeWaitHandle(BuildManagerAccessor.DesignTimeBuildAvailable, false);

                Thread t = new Thread(() =>
                {
                    BuildAvailableEvent.WaitOne();
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        Package.Instance.BuildNextProject();
                    }));
                });
                t.Start();
                return(false);
            }
            else
            {
                try
                {
                    Dictionary <string, string> properties = new Dictionary <string, string>();
                    String platform = buildCallback.ProjectConfiguration.PlatformName;
                    properties["Platform"]      = platform.Equals("Any CPU") ? "AnyCPU" : platform;
                    properties["Configuration"] = buildCallback.ProjectConfiguration.ConfigurationName;

                    BuildRequestData buildRequest = new BuildRequestData(
                        ProjectUtil.GetProjectFullPath(p),
                        properties,
                        null,
                        new String[] { "IceBuilder_Compile" },
                        project.ProjectCollection.HostServices,
                        BuildRequestDataFlags.IgnoreExistingProjectState |
                        BuildRequestDataFlags.ReplaceExistingProjectInstance);

                    BuildSubmission submission = BuildManager.DefaultBuildManager.PendBuildRequest(buildRequest);
                    ErrorHandler.ThrowOnFailure(BuildManagerAccessor.RegisterLogger(submission.SubmissionId, buildLogger));
                    buildCallback.BeginBuild();
                    submission.ExecuteAsync((s) =>
                    {
                        Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() =>
                        {
                            project.ProjectCollection.Loggers.Remove(buildLogger);
                            project.ProjectCollection.OnlyLogCriticalEvents = onlyLogCriticalEvents;
                            BuildManagerAccessor.ReleaseBuildResources(cookie);
                            BuildManagerAccessor.UnregisterLoggers(submission.SubmissionId);
                            buildCallback.EndBuild(submission.BuildResult.OverallResult == BuildResultCode.Success);
                        }));
                    }, null);

                    return(true);
                }
                catch (Exception)
                {
                    project.ProjectCollection.Loggers.Remove(buildLogger);
                    project.ProjectCollection.OnlyLogCriticalEvents = onlyLogCriticalEvents;
                    BuildManagerAccessor.ReleaseBuildResources(cookie);
                    throw;
                }
            }
        }