public void GetAssemblyNameFromFullNameTest() { using (Stream s = GetStreamForFile("MSBuild.Community.Tasks.csproj")) { ProjectFileParser p = new ProjectFileParser(s); Assert.AreEqual("Ionic.Zip.Reduced", p.GetAssemblyNameFromFullName("Ionic.Zip.Reduced, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL")); } }
/// <summary> /// Runs the task. /// </summary> /// <returns></returns> public override bool Execute() { if (InputFiles == null) { Log.LogError("No input files!"); return(false); } foreach (ITaskItem file in InputFiles) { var fullPath = file.GetMetadata("FullPath"); Log.LogMessage("Parsing " + fullPath); FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read); using (fs) { ProjectFileParser p = new ProjectFileParser(fs); if (!Filtered(p.GetAssemblyName())) { if (String.IsNullOrEmpty(p.GetAssemblyName())) { Log.LogWarning("Não foi possível identificar AssemblyName para: " + file.GetMetadata("FullPath")); } foreach (ProjectReference r in p.GetReferences()) { if (String.IsNullOrEmpty(p.GetAssemblyNameFromFullName(r.Include))) { Log.LogWarning("Não foi possível identificar referência encontrada em : " + file.GetMetadata("FullPath")); } if (!Filtered(p.GetAssemblyNameFromFullName(r.Include))) { AddDependency(p.GetAssemblyName(), p.GetAssemblyNameFromFullName(r.Include)); } } } } } Stream s = GenerateGraphVizOutput(); LogToConsole(s); LogToFile(s); return(true); }
/// <summary> /// Runs the task. /// </summary> /// <returns></returns> public override bool Execute() { if (InputFiles == null) { Log.LogError("No input files!"); return false; } foreach (ITaskItem file in InputFiles) { var fullPath = file.GetMetadata("FullPath"); Log.LogMessage("Parsing " + fullPath); FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read); using (fs) { ProjectFileParser p = new ProjectFileParser(fs); if (!Filtered(p.GetAssemblyName())) { if (String.IsNullOrEmpty(p.GetAssemblyName())) Log.LogWarning("Não foi possível identificar AssemblyName para: " + file.GetMetadata("FullPath")); foreach (ProjectReference r in p.GetReferences()) { if (String.IsNullOrEmpty(p.GetAssemblyNameFromFullName(r.Include))) Log.LogWarning("Não foi possível identificar referência encontrada em : " + file.GetMetadata("FullPath")); if (!Filtered(p.GetAssemblyNameFromFullName(r.Include))) AddDependency(p.GetAssemblyName(), p.GetAssemblyNameFromFullName(r.Include)); } } } } Stream s = GenerateGraphVizOutput(); LogToConsole(s); LogToFile(s); return true; }
private static string MakeDisplayName(string include) { var result = ProjectFileParser.GetAssemblyNameFromFullName(include); return(string.IsNullOrEmpty(result) ? include : result); }