-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 'Failed to resolve assembly' cecil issue #625
Fix 'Failed to resolve assembly' cecil issue #625
Conversation
private readonly string _modulePath; | ||
// this is lazy because we cannot create AspNetCoreSharedFrameworkResolver if not on .NET Core runtime, | ||
// runtime folders are different | ||
private readonly Lazy<CompositeCompilationAssemblyResolver> _compositeResolver = new Lazy<CompositeCompilationAssemblyResolver>(() => new CompositeCompilationAssemblyResolver(new ICompilationAssemblyResolver[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here build up composite resolver...so we check on defaults and also on aspnetcore shared folders at the end
|
||
using DependencyContextJsonReader contextJsonReader = new DependencyContextJsonReader(); | ||
Dictionary<string, Lazy<AssemblyDefinition>> libraries = new Dictionary<string, Lazy<AssemblyDefinition>>(); | ||
foreach (string fileName in Directory.GetFiles(Path.GetDirectoryName(_modulePath), "*.deps.json")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
search and load all deps files and try to resolve
} | ||
catch (AssemblyResolutionException) | ||
{ | ||
if (IsDotNetCore()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try manual resolving in case of .net app
} | ||
} | ||
|
||
internal class AspNetCoreSharedFrameworkResolver : ICompilationAssemblyResolver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asp.net core shared framework resolver, search inside folders
/// correct forwards. | ||
/// Check compares 'assembly name' and 'public key token', because versions could differ between runtimes. | ||
/// </summary> | ||
internal class NetstandardAwareAssemblyResolver : DefaultAssemblyResolver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved in new own file
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Closes #560 and improve scenario where we have to use
/p:CopyLocalLockFileAssemblies=true
In case of load issue we get
If we add
<PreserveCompilationContext>
custom load seem to work.thank's @rpatrick00 for the repro.
I ask to some guys that helped with solution to check if could work @livarcocc @dasMulli @nguerrera @dsplaisted @elinor-fung and @jbevain from which I took some piece of code for resolver.
We need to check if we're on core because we support also .NET Framework.
cc: @tonerdo @petli