public virtual void InvalidateGroup() { // Set keyOutput to null so that a refresh will be performed the next time // a property getter is called. if (null != keyOutput) { // Once the group is invalidated there is no more reason to listen for events. project.OnProjectPropertyChanged -= new EventHandler<ProjectPropertyChangedArgs>(OnProjectPropertyChanged); } keyOutput = null; }
public virtual void Refresh() { // Let MSBuild know which configuration we are working with project.SetConfiguration(projectCfg.ConfigCanonicalName); var result = new BuildResult(MSBuildResult.Failed, null); if (project.ProjectMgr.BuildProject.Targets.ContainsKey(ProjectFileConstants.AllProjectOutputGroups)) { result = project.InvokeMsBuild(ProjectFileConstants.AllProjectOutputGroups, false /*isBeingCalledByComputeSourcesAndFlags*/); if (!result.IsSuccessful) { // we could not compute it, probably because there is a real build going on right now project.SetCurrentConfiguration(); return; } } // Rebuild the content of our list of output string outputType = this.targetName + "Output"; this.outputs.Clear(); foreach (Microsoft.Build.Execution.ProjectItemInstance assembly in result.ProjectInstance.GetItems(outputType)) { Output output = new Output(project, assembly); this.outputs.Add(output); // See if it is our key output if (String.Compare(MSBuildItem.GetMetadataValue(assembly, "IsKeyOutput"), true.ToString(), StringComparison.OrdinalIgnoreCase) == 0) keyOutput = output; } project.SetCurrentConfiguration(); // Now that the group is built we have to check if it is invalidated by a property // change on the project. project.OnProjectPropertyChanged += new EventHandler<ProjectPropertyChangedArgs>(OnProjectPropertyChanged); }