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 void PopulateAssemblies(IDictionary <string, AssemblyEntry> assemblies, string path) { if (!Directory.Exists(path)) { return; } foreach (var assemblyPath in Directory.GetFiles(path, "*.dll")) { var name = Path.GetFileNameWithoutExtension(assemblyPath); var entry = new AssemblyEntry(); entry.Path = assemblyPath; assemblies[name] = entry; } }
private static void PopulateAssemblies(IDictionary<string, AssemblyEntry> assemblies, string path) { if (!Directory.Exists(path)) { return; } foreach (var assemblyPath in Directory.GetFiles(path, "*.dll")) { var name = Path.GetFileNameWithoutExtension(assemblyPath); var entry = new AssemblyEntry(); entry.Path = assemblyPath; assemblies[name] = entry; } }
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 void PopulateFromRedistList(DirectoryInfo directory, NuGetFramework targetFramework, string referenceAssembliesPath, 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); // Remember the original search paths, because we might need them later var originalSearchPaths = frameworkInfo.SearchPaths; // There are some frameworks, that "inherit" from a base framework, like // e.g. .NET 4.0.3, and MonoAndroid. var includeFrameworkVersion = frameworkList.Root.Attribute("IncludeFramework")?.Value; if (includeFrameworkVersion != null) { // Get the NuGetFramework identifier for the framework to include var includeFramework = NuGetFramework.Parse($"{targetFramework.Framework}, Version={includeFrameworkVersion}"); // Recursively call the code to get the framework information var includeFrameworkInfo = GetFrameworkInformation(includeFramework, referenceAssembliesPath); // Append the search paths of the included framework frameworkInfo.SearchPaths = frameworkInfo.SearchPaths.Concat(includeFrameworkInfo.SearchPaths).ToArray(); // Add the assemblies of the included framework foreach (var assemblyEntry in includeFrameworkInfo.Assemblies) { frameworkInfo.Assemblies[assemblyEntry.Key] = assemblyEntry.Value; } } // 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; IEnumerable <string> populateFromPaths; 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; populateFromPaths = new List <string> { resovledPath, Path.Combine(resovledPath, "Facades") }; } else { var emptyFileElements = true; foreach (var e in frameworkList.Root.Elements()) { // Remember that we had at least one framework assembly emptyFileElements = false; 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; } if (emptyFileElements) { // When we haven't found any file elements, we probably processed a // Mono/Xamarin FrameworkList.xml. That means, that we have to // populate the assembly list from the files. populateFromPaths = originalSearchPaths; } else { populateFromPaths = null; } } // Do we need to populate from search paths? if (populateFromPaths != null) { foreach (var populateFromPath in populateFromPaths) { PopulateAssemblies(frameworkInfo.Assemblies, populateFromPath); } } var nameAttribute = frameworkList.Root.Attribute("Name"); frameworkInfo.Name = nameAttribute == null ? null : nameAttribute.Value; } } }
private static void PopulateFromRedistList(DirectoryInfo directory, NuGetFramework targetFramework, string referenceAssembliesPath, 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); // Remember the original search paths, because we might need them later var originalSearchPaths = frameworkInfo.SearchPaths; // There are some frameworks, that "inherit" from a base framework, like // e.g. .NET 4.0.3, and MonoAndroid. var includeFrameworkVersion = frameworkList.Root.Attribute("IncludeFramework")?.Value; if (includeFrameworkVersion != null) { // Get the NuGetFramework identifier for the framework to include var includeFramework = NuGetFramework.Parse($"{targetFramework.Framework}, Version={includeFrameworkVersion}"); // Recursively call the code to get the framework information var includeFrameworkInfo = GetFrameworkInformation(includeFramework, referenceAssembliesPath); // Append the search paths of the included framework frameworkInfo.SearchPaths = frameworkInfo.SearchPaths.Concat(includeFrameworkInfo.SearchPaths).ToArray(); // Add the assemblies of the included framework foreach (var assemblyEntry in includeFrameworkInfo.Assemblies) { frameworkInfo.Assemblies[assemblyEntry.Key] = assemblyEntry.Value; } } // 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; IEnumerable<string> populateFromPaths; 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; populateFromPaths = new List<string> { resovledPath, Path.Combine(resovledPath, "Facades") }; } else { var emptyFileElements = true; foreach (var e in frameworkList.Root.Elements()) { // Remember that we had at least one framework assembly emptyFileElements = false; 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; } if (emptyFileElements) { // When we haven't found any file elements, we probably processed a // Mono/Xamarin FrameworkList.xml. That means, that we have to // populate the assembly list from the files. populateFromPaths = originalSearchPaths; } else { populateFromPaths = null; } } // Do we need to populate from search paths? if (populateFromPaths != null) { foreach (var populateFromPath in populateFromPaths) { PopulateAssemblies(frameworkInfo.Assemblies, populateFromPath); } } var nameAttribute = frameworkList.Root.Attribute("Name"); frameworkInfo.Name = nameAttribute == null ? null : nameAttribute.Value; } } }