public static IEnumerable <MBEV.ResolvedImport> Children(this MBEV.ResolvedImport import, MBEV.Project project) { return(project.Imports.Where( i => string.Equals(i.ImportingElement.ContainingProject.FullPath, project.ResolveAllProperties(import.ImportedProject.Location.File), StringComparison.OrdinalIgnoreCase))); }
public MSBuildImport(ResolvedImport imp) { FileInfo f = new FileInfo(imp.ImportedProject.FullPath); this.Name = f.Name; this.Source = imp.ImportedProject.FullPath; this.ToolsVersion = imp.ImportedProject.ToolsVersion; this.Condition = imp.ImportingElement.Condition; }
public void Trace(MBEV.ResolvedImport import, int traceLevel = 0) { PrintImportInfo(import, traceLevel); foreach (var childImport in import.Children(project)) { Trace(childImport, traceLevel + $"{import.ImportingElement.Location.Line}: ".Length); } }
private void PrintImportInfo(MBEV.ResolvedImport import, int indentLength) { var indent = indentLength > 0 ? new StringBuilder().Insert(0, " ", indentLength).ToString() : ""; Utils.WriteColor(indent, ConsoleColor.White); Utils.WriteColor($"{import.ImportingElement.Location.Line}: ", ConsoleColor.Cyan); var importedProjectFile = project.ResolveAllProperties(import.ImportedProject.Location.File); Utils.WriteColor(Path.GetDirectoryName(importedProjectFile) + Path.DirectorySeparatorChar, ConsoleColor.DarkGreen); Utils.WriteLineColor(Path.GetFileName(importedProjectFile), ConsoleColor.Green); if (!string.IsNullOrWhiteSpace(import.ImportingElement.Condition)) { Utils.WriteColor($"{indent}because ", ConsoleColor.DarkGray); Utils.WriteLineColor($"{import.ReducedCondition()}", ConsoleColor.DarkCyan); } Console.WriteLine(); }
public static string ReducedCondition(this MBEV.ResolvedImport import) { return(Regex.Replace(import.ImportingElement.Condition, @"Exists\('.+'\)", "the file exists", RegexOptions.IgnoreCase)); }