private static void PopulateFromRedistList(DirectoryInfo directory, FrameworkInformation frameworkInfo) { // The redist list contains the list of assemblies for this target framework string redistList = Path.Combine(directory.FullName, "RedistList", "FrameworkList.xml"); if (File.Exists(redistList)) { frameworkInfo.RedistListPath = redistList; using (var stream = File.OpenRead(redistList)) { var frameworkList = XDocument.Load(stream); // On mono, the RedistList.xml has an entry pointing to the TargetFrameworkDirectory // It basically uses the GAC as the reference assemblies for all .NET framework // profiles var targetFrameworkDirectory = frameworkList.Root.Attribute("TargetFrameworkDirectory")?.Value; if (!string.IsNullOrEmpty(targetFrameworkDirectory)) { // For some odd reason, the paths are actually listed as \ so normalize them here targetFrameworkDirectory = targetFrameworkDirectory.Replace('\\', Path.DirectorySeparatorChar); // The specified path is the relative path from the RedistList.xml itself var resovledPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(redistList), targetFrameworkDirectory)); // Update the path to the framework frameworkInfo.Path = resovledPath; PopulateAssemblies(frameworkInfo.Assemblies, resovledPath); PopulateAssemblies(frameworkInfo.Assemblies, Path.Combine(resovledPath, "Facades")); } else { foreach (var e in frameworkList.Root.Elements()) { var assemblyName = e.Attribute("AssemblyName").Value; var version = e.Attribute("Version")?.Value; var entry = new AssemblyEntry(); entry.Version = version != null?Version.Parse(version) : null; frameworkInfo.Assemblies[assemblyName] = entry; } } var nameAttribute = frameworkList.Root.Attribute("Name"); frameworkInfo.Name = nameAttribute == null ? null : nameAttribute.Value; } } }
private static FrameworkInformation GetFrameworkInformation(DirectoryInfo directory, NuGetFramework targetFramework) { var frameworkInfo = new FrameworkInformation(); frameworkInfo.Exists = true; frameworkInfo.Path = directory.FullName; frameworkInfo.SearchPaths = new[] { frameworkInfo.Path, Path.Combine(frameworkInfo.Path, "Facades") }; PopulateFromRedistList(directory, frameworkInfo); if (string.IsNullOrEmpty(frameworkInfo.Name)) { frameworkInfo.Name = SynthesizeFrameworkFriendlyName(targetFramework); } return(frameworkInfo); }
private static void PopulateFromRedistList(DirectoryInfo directory, FrameworkInformation frameworkInfo) { // The redist list contains the list of assemblies for this target framework string redistList = Path.Combine(directory.FullName, "RedistList", "FrameworkList.xml"); if (File.Exists(redistList)) { frameworkInfo.RedistListPath = redistList; using (var stream = File.OpenRead(redistList)) { var frameworkList = XDocument.Load(stream); // On mono, the RedistList.xml has an entry pointing to the TargetFrameworkDirectory // It basically uses the GAC as the reference assemblies for all .NET framework // profiles var targetFrameworkDirectory = frameworkList.Root.Attribute("TargetFrameworkDirectory")?.Value; if (!string.IsNullOrEmpty(targetFrameworkDirectory)) { // For some odd reason, the paths are actually listed as \ so normalize them here targetFrameworkDirectory = targetFrameworkDirectory.Replace('\\', Path.DirectorySeparatorChar); // The specified path is the relative path from the RedistList.xml itself var resovledPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(redistList), targetFrameworkDirectory)); // Update the path to the framework frameworkInfo.Path = resovledPath; PopulateAssemblies(frameworkInfo.Assemblies, resovledPath); PopulateAssemblies(frameworkInfo.Assemblies, Path.Combine(resovledPath, "Facades")); } else { foreach (var e in frameworkList.Root.Elements()) { var assemblyName = e.Attribute("AssemblyName").Value; var version = e.Attribute("Version")?.Value; var entry = new AssemblyEntry(); entry.Version = version != null ? Version.Parse(version) : null; frameworkInfo.Assemblies[assemblyName] = entry; } } var nameAttribute = frameworkList.Root.Attribute("Name"); frameworkInfo.Name = nameAttribute == null ? null : nameAttribute.Value; } } }
private static FrameworkInformation GetFrameworkInformation(DirectoryInfo directory, NuGetFramework targetFramework) { var frameworkInfo = new FrameworkInformation(); frameworkInfo.Exists = true; frameworkInfo.Path = directory.FullName; frameworkInfo.SearchPaths = new[] { frameworkInfo.Path, Path.Combine(frameworkInfo.Path, "Facades") }; PopulateFromRedistList(directory, frameworkInfo); if (string.IsNullOrEmpty(frameworkInfo.Name)) { frameworkInfo.Name = SynthesizeFrameworkFriendlyName(targetFramework); } return frameworkInfo; }
private static FrameworkInformation GetLegacyFrameworkInformation(NuGetFramework targetFramework, string referenceAssembliesPath) { var frameworkInfo = new FrameworkInformation(); // Always grab .NET 2.0 data var searchPaths = new List<string>(); var net20Dir = Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "Microsoft.NET", "Framework", "v2.0.50727"); if (!Directory.Exists(net20Dir)) { return null; } // Grab reference assemblies first, if present for this framework if (targetFramework.Version.Major == 3) { // Most specific first (i.e. 3.5) if (targetFramework.Version.Minor == 5) { var refAsms35Dir = Path.Combine(referenceAssembliesPath, "v3.5"); if (!string.IsNullOrEmpty(targetFramework.Profile)) { // The 3.5 Client Profile assemblies ARE in .NETFramework... it's weird. refAsms35Dir = Path.Combine(referenceAssembliesPath, ".NETFramework", "v3.5", "Profile", targetFramework.Profile); } if (Directory.Exists(refAsms35Dir)) { searchPaths.Add(refAsms35Dir); } } // Always search the 3.0 reference assemblies if (string.IsNullOrEmpty(targetFramework.Profile)) { // a) 3.0 didn't have profiles // b) When using a profile, we don't want to fall back to 3.0 or 2.0 var refAsms30Dir = Path.Combine(referenceAssembliesPath, "v3.0"); if (Directory.Exists(refAsms30Dir)) { searchPaths.Add(refAsms30Dir); } } } // .NET 2.0 reference assemblies go last (but only if there's no profile in the TFM) if (string.IsNullOrEmpty(targetFramework.Profile)) { searchPaths.Add(net20Dir); } frameworkInfo.Exists = true; frameworkInfo.Path = searchPaths.First(); frameworkInfo.SearchPaths = searchPaths; // Load the redist list in reverse order (most general -> most specific) for (int i = searchPaths.Count - 1; i >= 0; i--) { var dir = new DirectoryInfo(searchPaths[i]); if (dir.Exists) { PopulateFromRedistList(dir, frameworkInfo); } } if (string.IsNullOrEmpty(frameworkInfo.Name)) { frameworkInfo.Name = SynthesizeFrameworkFriendlyName(targetFramework); } return frameworkInfo; }
private static FrameworkInformation GetLegacyFrameworkInformation(NuGetFramework targetFramework, string referenceAssembliesPath) { var frameworkInfo = new FrameworkInformation(); // Always grab .NET 2.0 data var searchPaths = new List <string>(); var net20Dir = Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "Microsoft.NET", "Framework", "v2.0.50727"); if (!Directory.Exists(net20Dir)) { return(null); } // Grab reference assemblies first, if present for this framework if (targetFramework.Version.Major == 3) { // Most specific first (i.e. 3.5) if (targetFramework.Version.Minor == 5) { var refAsms35Dir = Path.Combine(referenceAssembliesPath, "v3.5"); if (!string.IsNullOrEmpty(targetFramework.Profile)) { // The 3.5 Client Profile assemblies ARE in .NETFramework... it's weird. refAsms35Dir = Path.Combine(referenceAssembliesPath, ".NETFramework", "v3.5", "Profile", targetFramework.Profile); } if (Directory.Exists(refAsms35Dir)) { searchPaths.Add(refAsms35Dir); } } // Always search the 3.0 reference assemblies if (string.IsNullOrEmpty(targetFramework.Profile)) { // a) 3.0 didn't have profiles // b) When using a profile, we don't want to fall back to 3.0 or 2.0 var refAsms30Dir = Path.Combine(referenceAssembliesPath, "v3.0"); if (Directory.Exists(refAsms30Dir)) { searchPaths.Add(refAsms30Dir); } } } // .NET 2.0 reference assemblies go last (but only if there's no profile in the TFM) if (string.IsNullOrEmpty(targetFramework.Profile)) { searchPaths.Add(net20Dir); } frameworkInfo.Exists = true; frameworkInfo.Path = searchPaths.First(); frameworkInfo.SearchPaths = searchPaths; // Load the redist list in reverse order (most general -> most specific) for (int i = searchPaths.Count - 1; i >= 0; i--) { var dir = new DirectoryInfo(searchPaths[i]); if (dir.Exists) { PopulateFromRedistList(dir, frameworkInfo); } } if (string.IsNullOrEmpty(frameworkInfo.Name)) { frameworkInfo.Name = SynthesizeFrameworkFriendlyName(targetFramework); } return(frameworkInfo); }