public MSBuildTarget(ProjectTargetInstance pti, Project project, MSBuildFile parent = null) { this.Target = pti; this.Name = pti.Name; this.Inputs = pti.Inputs; this.Outputs = pti.Outputs; this.Location = pti.FullPath; this.DependsOnTargets = pti.DependsOnTargets; this.TargetColor = "Black"; this.FontStyle = "Normal"; if (!string.IsNullOrEmpty(this.Target.Condition)) { this.TargetCondition = this.Target.Condition; this.TargetColor = "Gray"; this.FontStyle = "Italic"; } if (project.Xml.DefaultTargets.Contains(pti.Name)) { this.TargetColor = "MediumBlue"; } if (project.Xml.InitialTargets.Contains(pti.Name)) { this.TargetColor = "LimeGreen"; } if (project.Xml.InitialTargets.Contains(pti.Name) && project.Xml.DefaultTargets.Contains(pti.Name)) { this.TargetColor = "Gold"; } this.Targets = new ObservableCollection <MSBuildTarget>(); string targets = project.ExpandString(pti.DependsOnTargets); targets = this.formatRegex.Replace(targets, string.Empty); int i = 0; foreach (var target in targets.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { this.Targets.Add(new MSBuildTarget(target)); i++; } foreach (var x in project.Xml.Targets.Where(x => x.Name == pti.Name)) { this.BeforeTargets = x.BeforeTargets; this.AfterTargets = x.AfterTargets; } if (parent != null) { this.Parent = parent; } }
public MSBuildTarget(ProjectTargetInstance pti, Project project, MSBuildFile parent = null) { this.Target = pti; this.Name = pti.Name; this.Inputs = pti.Inputs; this.Outputs = pti.Outputs; this.Location = pti.FullPath; this.DependsOnTargets = pti.DependsOnTargets; this.TargetColor = "Black"; this.FontStyle = "Normal"; if (!string.IsNullOrEmpty(this.Target.Condition)) { this.TargetCondition = this.Target.Condition; this.TargetColor = "Gray"; this.FontStyle = "Italic"; } if (project.Xml.DefaultTargets.Contains(pti.Name)) { this.TargetColor = "MediumBlue"; } if (project.Xml.InitialTargets.Contains(pti.Name)) { this.TargetColor = "LimeGreen"; } if (project.Xml.InitialTargets.Contains(pti.Name) && project.Xml.DefaultTargets.Contains(pti.Name)) { this.TargetColor = "Gold"; } this.Targets = new ObservableCollection<MSBuildTarget>(); string targets = project.ExpandString(pti.DependsOnTargets); targets = this.formatRegex.Replace(targets, string.Empty); int i = 0; foreach (var target in targets.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { this.Targets.Add(new MSBuildTarget(target)); i++; } foreach (var x in project.Xml.Targets.Where(x => x.Name == pti.Name)) { this.BeforeTargets = x.BeforeTargets; this.AfterTargets = x.AfterTargets; } if (parent != null) { this.Parent = parent; } }
public int CompareTo(object obj) { MSBuildFile tempO = obj as MSBuildFile; if (tempO == null) { throw new ArgumentException("Object is not MSBuildFile"); } return(this.Name.CompareTo(tempO.Name)); }
internal static MSBuildFile GetFile(FileInfo file) { using (ProjectCollection loadedProjects = new ProjectCollection()) { Project currentProject = loadedProjects.GetLoadedProjects(file.FullName).FirstOrDefault(); if (currentProject != null) { loadedProjects.UnloadProject(currentProject); } loadedProjects.LoadProject(file.FullName); currentProject = loadedProjects.GetLoadedProjects(file.FullName).FirstOrDefault(); MSBuildFile m = new MSBuildFile(currentProject); if (currentProject.Targets != null) { SortedDictionary<string, ProjectTargetInstance> sortedTargets = new SortedDictionary<string, ProjectTargetInstance>(currentProject.Targets); foreach (var t in sortedTargets) { ProjectTargetInstance pti = t.Value; m.Targets.Add(new MSBuildTarget(pti, currentProject, m)); } } foreach (var us in currentProject.Xml.UsingTasks) { m.Usings.Add(new MSBuildUsing(currentProject, us)); } foreach (ResolvedImport import in currentProject.Imports) { m.Imports.Add(new MSBuildImport(import)); } foreach (var property in currentProject.Properties) { m.Properties.Add(new MSBuildProperties(property)); } if (currentProject.AllEvaluatedItems != null) { foreach (var item in currentProject.AllEvaluatedItems) { m.Items.Add(new MSBuildItems(item.ItemType, item.UnevaluatedInclude, item.EvaluatedInclude, item.IsImported)); } } return m; } }
public void PopulateXml(MSBuildFile f) { this.textBoxXml.Text = f != null ? f.ProjectFile.Xml.RawXml : string.Empty; }
public void PopulateUsings(MSBuildFile f) { this.usings = new ObservableCollection<MSBuildUsing>(); if (f != null) { this.usings = f.Usings; } this.dataGridUsings.ItemsSource = this.usings; foreach (TabItem t in from TabItem t in this.tabControlDetails.Items where t.Header.ToString().StartsWith("Usings") select t) { t.Header = this.usings.Count == 0 ? "Usings" : "Usings - " + this.usings.Count; } }
public void PopulateProperties(MSBuildFile f) { this.properties = new ObservableCollection<MSBuildProperties>(); if (f != null) { this.properties = f.Properties; } this.dataGridProperties.ItemsSource = this.properties; foreach (TabItem t in from TabItem t in this.tabControlDetails.Items where t.Header.ToString().StartsWith("Properties") select t) { t.Header = this.properties.Count == 0 ? "Properties" : "Properties - " + this.properties.Count; } }
public void PopulateAll(MSBuildFile f) { this.ClearTargetDetails(); this.PopulateUsings(f); this.PopulateProperties(f); this.PopulateItems(f); this.PopulateImports(f); this.PopulateXml(f); }