protected async Task <List <RefInfo> > GetRefInfosImpl(string configDir, string pack) { var sdk = await ZipDownloader.DownloadIfNedeed(configDir, WindowsUrl); var brokenDependencies = new[] { "system.printing", "presentationframework" }; var result = new List <RefInfo>(); var refDir = GetRefsDir(sdk, pack); var relative = Path.GetRelativePath(sdk, refDir).Replace('\\', '/'); var dlls = Directory.GetFiles(refDir, "*.dll"); PathAssemblyResolver resolver = null; if (dlls.All(x => Path.GetFileName(x) != "mscorlib.dll")) { // Locate mscorlib require for MetadataLoadContext var mscorlibDir = GetRefsDir(sdk, "Microsoft.NETCore.App.Ref"); resolver = new PathAssemblyResolver(dlls.Union(new[] { Path.Combine(mscorlibDir, "mscorlib.dll") })); } else { resolver = new PathAssemblyResolver(dlls); } using var lc = new MetadataLoadContext(resolver); var known = dlls.Select(x => Path.GetFileNameWithoutExtension(x).ToLower()).ToArray(); foreach (var d in dlls) { try { var metadata = lc.LoadFromAssemblyPath(d); var deps = metadata.GetReferencedAssemblies(); var depNames = deps .Where(y => !brokenDependencies.Contains(y.Name.ToLower()) && known.Contains(y.Name.ToLower())) .Select(x => $"\":{x.Name.ToLower()}.dll\""); var name = Path.GetFileName(d); var refname = $"@core_sdk_{Version}//:core/{relative}/{name}"; var stdlibname = GetStdlibPath(sdk, name, pack, InternalVersionFolder, Version); var refInfo = new RefInfo(); refInfo.Name = name.ToLower(); refInfo.Version = metadata.GetName().Version.ToString(); refInfo.Ref = refname; refInfo.StdlibPath = stdlibname; refInfo.Pack = pack; refInfo.Deps.AddRange(depNames); if (stdlibname != null) { result.Add(refInfo); } } catch (Exception) { } } return(result); }
public override async Task <List <RefInfo> > GetRefInfos(string configDir) { var package = await PackageDownloader.DownloadPackageIfNedeed(configDir, "Microsoft.NETCore.App", InternalVersionFolder); var sdkDir = await ZipDownloader.DownloadIfNedeed(configDir, WindowsUrl); var brokenDependencies = new string[] { "netstandard" }; var result = new List <RefInfo>(); var packageDir = Path.Combine(package, "packages", $"Microsoft.NETCore.App.{InternalVersionFolder}"); var frameworkDir = Path.Combine(packageDir, "ref"); frameworkDir = Directory.GetDirectories(frameworkDir).OrderByDescending(x => x).First(); var relative = Path.GetRelativePath(packageDir, frameworkDir).Replace('\\', '/'); var dlls = Directory.GetFiles(frameworkDir, "*.dll"); var resolver = new PathAssemblyResolver(dlls); using var lc = new MetadataLoadContext(resolver); var known = dlls.Select(x => Path.GetFileNameWithoutExtension(x).ToLower()).ToArray(); foreach (var d in dlls) { try { var metadata = lc.LoadFromAssemblyPath(d); var deps = metadata.GetReferencedAssemblies(); var depNames = deps .Where(y => !brokenDependencies.Contains(y.Name.ToLower()) && known.Contains(y.Name.ToLower())) .Select(x => $"\":{x.Name.ToLower()}.dll\""); var name = Path.GetFileName(d); var refname = $"@Microsoft.NETCore.App.{InternalVersionFolder}//:{relative}/{name}"; var stdlibpath = GetStdlibPath(sdkDir, name, InternalVersionFolder, Version); var refInfo = new RefInfo(); refInfo.Name = name.ToLower(); refInfo.Version = metadata.GetName().Version.ToString(); refInfo.Ref = refname; refInfo.StdlibPath = stdlibpath; refInfo.Pack = null; refInfo.Deps.AddRange(depNames); result.Add(refInfo); } catch (Exception) { } } return(result); }
private List <RefInfo> GetRefInfos(string srcDir, string package, string version) { var brokenDependencies = new string[] { "system.xml", "system.configuration", "system.windows.forms", "system.runtime.remoting", "system.transactions", "system.design", "system.web", "presentationframework", "system.printing", "system.servicemodel", "system.data.services.design", "system.workflow.activities", "system.data" }; var result = new List <RefInfo>(); var packageDir = GetPackagePath(srcDir, package, version); var frameworkDir = GetRefsDir(srcDir, package, version); var facadeDir = Path.Combine(frameworkDir, "Facades"); var relative = Path.GetRelativePath(packageDir, frameworkDir).Replace('\\', '/'); var dlls = Directory.GetFiles(frameworkDir, "*.dll"); var facades = Directory.Exists(facadeDir) ? Directory.GetFiles(facadeDir, "*.dll") : new string[] { }; var allDlls = dlls.Union(facades); var resolver = new PathAssemblyResolver(allDlls); using var lc = new MetadataLoadContext(resolver); var known = allDlls.Select(x => Path.GetFileNameWithoutExtension(x).ToLower()).ToArray(); foreach (var d in allDlls) { try { var metadata = lc.LoadFromAssemblyPath(d); var deps = metadata.GetReferencedAssemblies(); var depNames = deps .Where(y => !brokenDependencies.Contains(y.Name.ToLower()) && known.Contains(y.Name.ToLower())) .Select(x => $"\":{x.Name.ToLower()}.dll\""); var name = Path.GetFileName(d); var refname = facades.Contains(d) ? $"@{package}.{version}//:{relative}/Facades/{name}" : $"@{package}.{version}//:{relative}/{name}"; var refInfo = new RefInfo(); refInfo.Name = name.ToLower(); refInfo.Version = metadata.GetName().Version.ToString(); refInfo.Ref = refname; refInfo.StdlibPath = refname; // Real implementation assemblies are in GAC refInfo.Deps.AddRange(depNames); result.Add(refInfo); } catch (Exception) { } } return(result); }
private List <RefInfo> GetRefInfos(string srcDir) { var brokenDependencies = new string[] { "system.xml", "system.configuration", "system.windows.forms", "system.runtime.remoting", "system.transactions", "system.design", "system.web", "presentationframework", "system.printing", "system.servicemodel", "system.data.services.design", "system.workflow.activities", "system.data" }; var result = new List <RefInfo>(); var dlls = Directory.GetFiles(srcDir, "*.dll"); var facades = Directory.GetFiles(Path.Combine(srcDir, "Facades"), "*.dll"); var allDlls = dlls.Union(facades); var resolver = new PathAssemblyResolver(allDlls); using var lc = new MetadataLoadContext(resolver); var known = allDlls.Select(x => Path.GetFileNameWithoutExtension(x).ToLower()).ToArray(); foreach (var d in allDlls) { try { var metadata = lc.LoadFromAssemblyPath(d); var deps = metadata.GetReferencedAssemblies(); var depNames = deps .Where(y => !brokenDependencies.Contains(y.Name.ToLower()) && known.Contains(y.Name.ToLower())) .Select(x => $"\":{x.Name.ToLower()}.dll\""); var name = Path.GetFileName(d); var refname = facades.Contains(d) ? $"@Mono.ReferenceAssemblies.v4.5//:build/.NETFramework/v4.5/Facades/{name}" : $"@Mono.ReferenceAssemblies.v4.5//:build/.NETFramework/v4.5/{name}"; var refInfo = new RefInfo(); refInfo.Name = name.ToLower(); refInfo.Version = metadata.GetName().Version.ToString(); refInfo.Ref = refname; refInfo.Deps.AddRange(depNames); result.Add(refInfo); } catch (Exception) { } } return(result); }
private List <RefInfo> GetRefInfos(string srcDir, string package, string version, string sdkDir, string sdkVersion) { var brokenDependencies = new string[] { "netstandard" }; var result = new List <RefInfo>(); var packageDir = GetPackagePath(srcDir, package, version); var frameworkDir = GetRefsDir(srcDir, package, version); var relative = Path.GetRelativePath(packageDir, frameworkDir).Replace('\\', '/'); var dlls = Directory.GetFiles(frameworkDir, "*.dll"); var resolver = new PathAssemblyResolver(dlls); using var lc = new MetadataLoadContext(resolver); var known = dlls.Select(x => Path.GetFileNameWithoutExtension(x).ToLower()).ToArray(); foreach (var d in dlls) { try { var metadata = lc.LoadFromAssemblyPath(d); var deps = metadata.GetReferencedAssemblies(); var depNames = deps .Where(y => !brokenDependencies.Contains(y.Name.ToLower()) && known.Contains(y.Name.ToLower())) .Select(x => $"\":{x.Name.ToLower()}.dll\""); var name = Path.GetFileName(d); var refname = $"@{package}.{version}//:{relative}/{name}"; var stdlibpath = GetStdlibPath(sdkDir, name, version, sdkVersion); var refInfo = new RefInfo(); refInfo.Name = name.ToLower(); refInfo.Ref = refname; refInfo.StdlibPath = stdlibpath; refInfo.Deps.AddRange(depNames); result.Add(refInfo); } catch (Exception) { } } return(result); }
public static List <RefInfo> GetSdkInfos(string sdkd, string package, Sdk sdk) { var brokenDependencies = new string[] { }; var result = new List <RefInfo>(); var sdkDir = Path.Combine(sdkd, "shared", package, sdk.InternalVersionFolder); var dlls = Directory.GetFiles(sdkDir, "*.dll"); var resolver = new PathAssemblyResolver(dlls); using var lc = new MetadataLoadContext(resolver); var known = dlls.Select(x => Path.GetFileNameWithoutExtension(x).ToLower()).ToArray(); foreach (var d in dlls) { try { var metadata = lc.LoadFromAssemblyPath(d); var deps = metadata.GetReferencedAssemblies(); var depNames = deps .Where(y => !brokenDependencies.Contains(y.Name.ToLower()) && known.Contains(y.Name.ToLower())) .Select(x => $"\":{x.Name.ToLower()}.dll\""); var name = Path.GetFileName(d); var refInfo = new RefInfo(); refInfo.Name = name.ToLower(); refInfo.Version = metadata.GetName().Version.ToString(); refInfo.StdlibPath = $"@core_sdk_{sdk.Version}//:core/shared/Microsoft.NETCore.App/{sdk.InternalVersionFolder}/{name}"; refInfo.Ref = $"@core_sdk_{sdk.Version}//:core/shared/Microsoft.NETCore.App/{sdk.InternalVersionFolder}/{name}"; refInfo.Deps.AddRange(depNames); result.Add(refInfo); } catch (Exception) { } } return(result); }
private List <RefInfo> GetSdkInfos(string sdk, string package, string version) { var brokenDependencies = new string[] { }; var result = new List <RefInfo>(); var sdkDir = Path.Combine(sdk, "shared", package, version); var dlls = Directory.GetFiles(sdkDir, "*.dll"); var resolver = new PathAssemblyResolver(dlls); using var lc = new MetadataLoadContext(resolver); var known = dlls.Select(x => Path.GetFileNameWithoutExtension(x).ToLower()).ToArray(); foreach (var d in dlls) { try { var metadata = lc.LoadFromAssemblyPath(d); var deps = metadata.GetReferencedAssemblies(); var depNames = deps .Where(y => !brokenDependencies.Contains(y.Name.ToLower()) && known.Contains(y.Name.ToLower())) .Select(x => $"\":{x.Name.ToLower()}.dll\""); var name = Path.GetFileName(d); var refInfo = new RefInfo(); refInfo.Name = name.ToLower(); refInfo.Deps.AddRange(depNames); result.Add(refInfo); } catch (Exception) { } } return(result); }