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

Failed to resolve assembly. #21

Closed
pms1969 opened this issue Mar 28, 2018 · 10 comments
Closed

Failed to resolve assembly. #21

pms1969 opened this issue Mar 28, 2018 · 10 comments

Comments

@pms1969
Copy link
Contributor

pms1969 commented Mar 28, 2018

Hi. Firstly, thanks for your efforts. By far the best approach I've seen so far in this space.

I've got a rather large solution with many interdependencies between projects. When I run my tests, for almost all of the projects I see the following error:

tests/MyAssembly.Tests
/src/packages/coverlet.msbuild/1.0.1/build/netstandard2.0/coverlet.msbuild.targets(7,5): error : Failed to resolve assembly: 'AnotherAssembly, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null' [/src/tests/MyAssembly.Tests/MyAssembly.Tests.csproj]

obviously sanitised.

AnotherAssembly isn't a direct dependency of the TestProject, but is built - to the version specified, and is in the bin directory along with all the other dependencies.

Any idea what might be wrong? Or better still, teach a bloke to fish: Is there some way of turning up the logging on coverlet to help debug? (can't actually say I've seen anything in the code which looks like it might help with this, but I haven't specifically been looking for it. will look now)

Cheers,
Paul

@tonerdo
Copy link
Collaborator

tonerdo commented Mar 29, 2018

Debug logging is something I've been hoping to add to coverlet. Do you have a simple repro project I can take a look at?

@pms1969
Copy link
Contributor Author

pms1969 commented Mar 29, 2018

Unfortunately not. I did try to set one up, but not knowing what the problem was, meant I couldn't get the test repo into the same state as our production one. :-( And I can't hand that over. :-s

I've added some Console.WriteLines in the spots I think will give me some kind of understanding and am in the process of trying to compile and publish locally. Will let you know how I get on.

@pms1969
Copy link
Contributor Author

pms1969 commented Mar 29, 2018

I'm not there yet, but here's an update:
It's happening on the module.Write(stream) line in Instrumenter: InstrumentModule method.

So basically inside Cecil.

I'm working on a theory. If it pans out, I'll report back. Otherwise, any thoughts?

@tonerdo
Copy link
Collaborator

tonerdo commented Mar 29, 2018

My best guess is that when Cecil rewrites the assembly it misses out the references but I can't be so sure. Lemme know how your theory pans out

@pms1969
Copy link
Contributor Author

pms1969 commented Mar 29, 2018

Theory didn't pan out. Looks like it's 2 specific Assemblies that have the issue. Ensuring that the dependency it's failing to find is instrumented first didn't do anything to improve the situation, so still stumbling around in the dark.

@pms1969
Copy link
Contributor Author

pms1969 commented Mar 29, 2018

Just opening and re-writing the assemblies with mono.cecil causes the error. Something fishy there :-( Might take me a while to track down.

@tonerdo
Copy link
Collaborator

tonerdo commented Apr 2, 2018

Can I see the unsanitized error output?

@pms1969
Copy link
Contributor Author

pms1969 commented Apr 3, 2018

@tonerdo I could, but it's literally the same as what you see. It's just the assembly names that were changed.

As it turns out. I have been able to track down the error, and come up with a solution. mono.cecil's assembly resolver doesn't search the module path. Some context here: (jbevain/cecil#306) and (jbevain/cecil#487). By taking the DotnetAssemblyResolver that @uhrm outlines in issue 306, and modifying it a touch, I was able to get what I needed. I've literally just got that working, so I'll try and get it tidied up, and get a PR back to you shortly.

@tonerdo
Copy link
Collaborator

tonerdo commented Apr 3, 2018

@pms1969 #23 has been merged in

@Structed
Copy link

Structed commented Nov 8, 2018

If still running into this issue though you consume a package which has the fix included, this fixed it for me: #33 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants