Skip to content
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

Load .deps.json using file and not assembly #3834

Closed
MarcoRossignoli opened this issue Nov 8, 2019 · 3 comments
Closed

Load .deps.json using file and not assembly #3834

MarcoRossignoli opened this issue Nov 8, 2019 · 3 comments

Comments

@MarcoRossignoli
Copy link
Member

Is there a way to load and inspect targets and libraries using Microsoft.Extensions.DependencyModel.DependencyContext passing a path to dep file?

I need to load dep file to try to locate and load dll during instrumentation(Mono.Cecil) inside a msbuild task(coverlet coverage), https://github.com/dotnet/cli/issues/12705#issuecomment-547996287

Some context, coverlet need to instrument dll and we use Mono.Cecil to do that...instrumentation is started by "drivers"(msbuild task, console app or vstest collectors), cecil search for dll in "current" test assembly directory but sometime that dll isn't present(assets are not moved to bin folder but are resolved at runtime o in publish phase from nuget package folder) so we get a fail for lib not found.

My idea is to "load" target deps file and manually(cecil has got a customizable resolver) load and return dll to cecil.
At the moment the only other solution is to "manually" copy dll to output folder, but it's not so easy/friendly and it's weak.

@MarcoRossignoli MarcoRossignoli changed the title Load .dep.json using file and not assembly Load .deps.json using file and not assembly Nov 8, 2019
@elinor-fung
Copy link
Member

It sounds like you are looking for DependencyContextJsonReader.

@MarcoRossignoli
Copy link
Member Author

Uh missing that I'll give it a try and come back thanks!

@MarcoRossignoli
Copy link
Member Author

Thank's works as expected!

@msftgits msftgits transferred this issue from dotnet/core-setup Jan 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants