Created
December 18, 2019 21:29
-
-
Save devhawk/6266f29181e822a09de7874d0842f5ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.IO; | |
| using System.Linq; | |
| using Microsoft.Extensions.DependencyModel; | |
| using Microsoft.Extensions.DependencyModel.Resolution; | |
| namespace TestDependencyModel | |
| { | |
| class Program | |
| { | |
| const string PATH = @"<path to contract.deps.json file here>"; | |
| public static void Main(string[] args) | |
| { | |
| using var stream = File.OpenRead(PATH); | |
| var reader = new DependencyContextJsonReader(); | |
| var dc = reader.Read(stream); | |
| var resolver = new CompositeCompilationAssemblyResolver( | |
| new ICompilationAssemblyResolver[] | |
| { | |
| new AppBaseCompilationAssemblyResolver(Path.GetDirectoryName(PATH)), | |
| new ReferenceAssemblyPathResolver(), | |
| new PackageCompilationAssemblyResolver() | |
| }); | |
| foreach (var library in dc.RuntimeLibraries) | |
| { | |
| var cl = new CompilationLibrary( | |
| library.Type, | |
| library.Name, | |
| library.Version, | |
| library.Hash, | |
| library.RuntimeAssemblyGroups.SelectMany(g => g.AssetPaths), | |
| library.Dependencies, | |
| library.Serviceable); | |
| var assemblies = new List<string>(); | |
| resolver.TryResolveAssemblyPaths(cl, assemblies); | |
| Console.WriteLine($"{library.Name} ({library.Type})"); | |
| foreach (var a in assemblies) | |
| { | |
| Console.WriteLine($" {a}"); | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment