예제 #1
0
        /// <summary>
        /// Disposes the project node object.
        /// </summary>
        /// <param name="disposing">Flag determining ehether it was deterministic or non deterministic clean up.</param>
        protected override void Dispose(bool disposing)
        {
            if (this.isDisposed)
            {
                return;
            }

            try
            {
                try
                {
                    this.UnRegisterProject();
                }
                finally
                {
                    try
                    {
                        this.RegisterClipboardNotifications(false);
                    }
                    finally
                    {
                        try
                        {
                            if (this.projectEventsProvider != null)
                            {
                                this.projectEventsProvider.AfterProjectFileOpened -= this.OnAfterProjectOpen;
                            }
                            if (this.taskProvider != null)
                            {
                                taskProvider.Tasks.Clear();
                                this.taskProvider.Dispose();
                                this.taskProvider = null;
                            }

                            if (this.buildLogger != null)
                            {
                                this.buildLogger.Shutdown();
                                buildLogger = null;
                            }

                            if (this.site != null)
                            {
                                this.site.Dispose();
                            }
                        }
                        finally
                        {
                            this.buildEngine = null;
                        }
                    }
                }

                if (this.buildProject != null)
                {
                    this.buildProject.ProjectCollection.UnloadProject(this.buildProject);
                    this.buildProject.ProjectCollection.UnloadProject(this.buildProject.Xml);
                    this.buildProject = null;
                }

                if (null != imageHandler)
                {
                    imageHandler.Close();
                    imageHandler = null;
                }
            }
            finally
            {
                base.Dispose(disposing);
                this.isDisposed = true;
            }
        }
예제 #2
0
            internal void Build(Project project, string targets, BuildRequestDataFlags flags, Microsoft.Build.Utilities.Logger logger)
            {
                if (project is null)
                {
                    throw new ArgumentNullException(nameof(project));
                }
                if (logger is null)
                {
                    throw new ArgumentNullException(nameof(logger));
                }

                // Make sure that we are using the project collection from the loaded project, otherwise we are getting
                // weird cache behavior with the MSBuild system
                var projectInstance = new ProjectInstance(project.Xml, project.ProjectCollection.GlobalProperties, project.ToolsVersion, project.ProjectCollection);

                BuildTask = Task.Run(() =>
                {
                    var buildResult = mainBuildManager.Build(
                        new BuildParameters(project.ProjectCollection)
                    {
                        Loggers = new[] { logger }
                    },
                        new BuildRequestData(projectInstance, targets.Split(';'), null, flags));

                    return(buildResult);
                });
            }
예제 #3
0
		/// <summary>
		/// Associate window output pane to the build logger
		/// </summary>
		/// <param name="output"></param>
		protected virtual void SetOutputLogger(IVsOutputWindowPane output)
		{
			// Create our logger, if it was not specified
			if(!this.useProvidedLogger || this.buildLogger == null)
			{
				// Because we may be aggregated, we need to make sure to get the outer IVsHierarchy
				IntPtr unknown = IntPtr.Zero;
				IVsHierarchy hierarchy = null;
				try
				{
					unknown = Marshal.GetIUnknownForObject(this);
					hierarchy = Marshal.GetTypedObjectForIUnknown(unknown, typeof(IVsHierarchy)) as IVsHierarchy;
				}
				finally
				{
					if(unknown != IntPtr.Zero)
						Marshal.Release(unknown);
				}
				// Create the logger
				this.buildLogger = new IDEBuildLogger(output, this.TaskProvider, hierarchy);

				// To retrive the verbosity level, the build logger depends on the registry root 
				// (otherwise it will used an hardcoded default)
				ILocalRegistry2 registry = this.GetService(typeof(SLocalRegistry)) as ILocalRegistry2;
				if(null != registry)
				{
					string registryRoot;
					ErrorHandler.ThrowOnFailure(registry.GetLocalRegistryRoot(out registryRoot));
					IDEBuildLogger logger = this.BuildLogger as IDEBuildLogger;
					if(!String.IsNullOrEmpty(registryRoot) && (null != logger))
					{
						logger.BuildVerbosityRegistryRoot = registryRoot;
						logger.ErrorString = this.ErrorString;
						logger.WarningString = this.WarningString;
					}
				}
			}
			else
			{
				((IDEBuildLogger)this.BuildLogger).OutputWindowPane = output;
			}

			if(this.buildEngine != null)
			{
				this.buildEngine.UnregisterAllLoggers();
				this.buildEngine.RegisterLogger(this.buildLogger);
			}
		}
예제 #4
0
		/// <summary>
		/// Disposes the project node object.
		/// </summary>
		/// <param name="disposing">Flag determining ehether it was deterministic or non deterministic clean up.</param>
		protected override void Dispose(bool disposing)
		{
			if(this.isDisposed)
			{
				return;
			}

			try
			{
				try
				{
					this.UnRegisterProject();
				}
				finally
				{
					try
					{
						this.RegisterClipboardNotifications(false);
					}
					finally
					{
						try
						{
							if(this.globalPropertyHandler != null)
							{
								this.globalPropertyHandler.ActiveConfigurationChanged -= new EventHandler<ActiveConfigurationChangedEventArgs>(this.OnHandleConfigurationRelatedGlobalProperties);

								this.globalPropertyHandler.Dispose();
							}

							if(this.projectEventsProvider != null)
							{
								this.projectEventsProvider.AfterProjectFileOpened -= this.OnAfterProjectOpen;
							}
							if(this.taskProvider != null)
							{
								taskProvider.Tasks.Clear();
								this.taskProvider.Dispose();
								this.taskProvider = null;
							}
							if(buildLogger != null)
							{
								buildLogger = null;
							}
							this.site = null;
						}
						finally
						{
							if(this.buildEngine != null)
							{
								this.buildEngine.UnregisterAllLoggers();
								this.buildEngine = null;
							}
						}
					}
				}

				if(this.buildProject != null)
				{
					this.buildProject.ParentEngine.UnloadProject(this.buildProject);
					this.buildProject = null;
				}

				if(null != imageHandler)
				{
					imageHandler.Close();
					imageHandler = null;
				}
			}
			finally
			{
				base.Dispose(disposing);
				this.isDisposed = true;
			}
		}
예제 #5
0
        /// <summary>
        /// Disposes the project node object.
        /// </summary>
        /// <param name="disposing">Flag determining ehether it was deterministic or non deterministic clean up.</param>
        protected override void Dispose(bool disposing)
        {
            if (this.isDisposed)
            {
                return;
            }

            try
            {
                try
                {
                    this.UnRegisterProject();
                }
                finally
                {
                    try
                    {
                        this.RegisterClipboardNotifications(false);
                    }
                    finally
                    {
                        try
                        {

                            if (this.projectEventsProvider != null)
                            {
                                this.projectEventsProvider.AfterProjectFileOpened -= this.OnAfterProjectOpen;
                            }
                            if (this.taskProvider != null)
                            {
                                this.taskProvider.Tasks.Clear();
                                this.taskProvider.Refresh();
                                this.taskProvider.Dispose();
                                this.taskProvider = null;
                            }
                            if (buildLogger != null)
                            {
                                buildLogger = null;
                            }
                            this.site = null;
                        }
                        finally
                        {
                            if (this.buildEngine != null)
                            {
                                this.buildEngine.UnregisterAllLoggers();
                                this.buildEngine = null;
                            }
                        }
                    }
                }

                if (this.buildProject != null)
                {
                    //this.projectInstance = null;
                    MSBuildProject.FullyUnloadProject(this.buildProject.ProjectCollection, this.buildProject);
                    SetBuildProject(null);
                }

                if (null != imageHandler)
                {
                    imageHandler.Close();
                    imageHandler = null;
                }
            }
            finally
            {
                base.Dispose(disposing);
                this.isDisposed = true;
            }
        }
예제 #6
0
            internal void Build(Task previousTask, Microsoft.Build.Evaluation.Project project, string targets, BuildRequestDataFlags flags, Microsoft.Build.Utilities.Logger logger)
            {
                if (project == null)
                {
                    throw new ArgumentNullException("project");
                }
                if (logger == null)
                {
                    throw new ArgumentNullException("logger");
                }

                // Make sure that we are using the project collection from the loaded project, otherwise we are getting
                // weird cache behavior with the msbuild system
                var projectInstance = new ProjectInstance(project.Xml, project.ProjectCollection.GlobalProperties, null, project.ProjectCollection);

                BuildTask = previousTask.ContinueWith(completedPreviousTask =>
                {
                    var buildResult = mainBuildManager.Build(
                        new BuildParameters(project.ProjectCollection)
                    {
                        Loggers = new[] { logger }
                    },
                        new BuildRequestData(projectInstance, targets.Split(';'), null, flags));

                    return(buildResult);
                });
            }
예제 #7
0
        /// <summary>
        /// Closes the project node.
        /// </summary>
        /// <returns>A success or failure value.</returns>
        public override int Close()
        {
            int hr = VSConstants.S_OK;

            try
            {
                this.UnRegisterProject();
            }
            catch (COMException e)
            {
                Trace.WriteLine(e);
                hr = e.ErrorCode;
            }
            finally
            {
                try
                {
                    this.RegisterClipboardNotifications(false);
                    hr = ErrorHandler.ThrowOnFailure(base.Close());
                }
                catch (COMException e)
                {
                    Trace.WriteLine(e);
                    hr = e.ErrorCode;
                }
                finally
                {
                    try
                    {
                        if (this.projectEventsProvider != null)
                        {
                            this.projectEventsProvider.AfterProjectFileOpened -= this.OnAfterProjectOpen;
                        }
                        if (this.taskProvider != null)
                        {
                            taskProvider.Tasks.Clear();
                            this.taskProvider.Dispose();
                            this.taskProvider = null;
                        }
                        if (buildLogger != null)
                        {
                            buildLogger = null;
                        }
                        this.site = null;
                        this.isClosed = true;
                    }
                    finally
                    {
                        if (this.buildEngine != null)
                        {
                            this.buildEngine.UnregisterAllLoggers();
                            this.buildEngine = null;
                        }
                    }
                }
            }
            try
            {
                if (this.buildProject != null)
                {
                    this.buildProject.ParentEngine.UnloadProject(this.buildProject);
                    this.buildProject = null;
                }
                if (null != imageHandler)
                {
                    imageHandler.Close();
                    imageHandler = null;
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
                Debug.Fail(e.Message);
            }
            return hr;
        }