Skip to content

Global Coverlet - nunit-console could not load file or assembly #525

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

Closed
StefanKoenigMUC opened this issue Aug 20, 2019 · 6 comments
Closed
Labels
duplicate This issue or pull request already exists

Comments

@StefanKoenigMUC
Copy link

Hi all,

i've just started to add coverage testing to some of our testing-suites, until now everything worked out fine - but i'm failing during my latest project.

My current test is executed with the following command (pretty straight forward):
nunit-console.exe Deploy\Test.Project.Integration.InMemory.Test.dll /xml=guiservice-nunit-result.xml

so i execute it by using global coverlet by usage of
coverlet Deploy/Test.Project.Integration.InMemory.Test.dll --target "nunit-console" --targetargs "Deploy/Test.Project.Integration.InMemory.Test.dll" -f=cobertura --output BuildReports\Coverage

which results in verbose output:

	Excluded module filter '[xunit*]*'
Included module filter 'Deploy\*.dll'
Instrumented module: 'deploy\Test.Project.Default.dll'
Instrumented module: 'deploy\Test.Project.dll'
Instrumented module: 'deploy\Test.Project.Grandfather.dll'
Instrumented module: 'deploy\Test.Project.Integration.dll'
Instrumented module: 'deploy\Test.Project.Integration.Fm1.dll'
Instrumented module: 'deploy\Test.Project.Integration.InMemory.dll'
Instrumented module: 'deploy\Test.Project.Integration.InMemory.Portable.dll'
Instrumented module: 'deploy\Test.Project.Persistence.dll'
Instrumented module: 'deploy\Test.Project.Persistence.File.dll'
Instrumented module: 'deploy\Test.Project.Persistence.Intermediate.Data.dll'
Instrumented module: 'deploy\Test.Project.Persistence.Intermediate.dll'
Instrumented module: 'deploy\Test.Project.Persistence.Intermediate.Fm1.dll'
Instrumented module: 'deploy\Test.Project.Persistence.Intermediate.Fm1.Grandfather.dll'
Instrumented module: 'deploy\Test.Util.dll'
[...]
Errors and Failures:
1) Test Error : Test.Project.Integration.InMemory.Test.Tester.ExecuteTestCase("Static\\TestCases\\test2.test")
   System.IO.FileLoadException : Die Datei oder Assembly "Test.Project.Integration.InMemory.Portable, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42a80d8b2633992e" oder eine Abhängigkeit davon wurde nicht gefunden. Die Signatur mit starkem Namen konnte nicht überprüft werden. Die Assembly wurde möglicherweise geändert oder verzögert aber nicht vollständig mit dem richtigen privaten Schlüssel signiert. (Ausnahme von HRESULT: 0x80131045)
   bei Test.Project.Integration.InMemory.Test.Tester.ExecuteTestCase(String testCasePath)
2) Test Error : Test.Project.Integration.InMemory.Test.Tester.ExecuteTestCase("Static\\TestCases\\DasIstEinTestfall.test")
   System.IO.FileLoadException : Die Datei oder Assembly "Test.Project.Integration.InMemory.Portable, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42a80d8b2633992e" oder eine Abhängigkeit davon wurde nicht gefunden. Die Signatur mit starkem Namen konnte nicht überprüft werden. Die Assembly wurde möglicherweise geändert oder verzögert aber nicht vollständig mit dem richtigen privaten Schlüssel signiert. (Ausnahme von HRESULT: 0x80131045)
   bei Test.Project.Integration.InMemory.Test.Tester.ExecuteTestCase(String testCasePath)
3) Test Error : Test.Project.Integration.InMemory.Test.Tester.ExecuteTestCase("Static\\TestCases\\test.test")
   System.IO.FileLoadException : Die Datei oder Assembly "Test.Project.Integration.InMemory.Portable, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42a80d8b2633992e" oder eine Abhängigkeit davon wurde nicht gefunden. Die Signatur mit starkem Namen konnte nicht überprüft werden. Die Assembly wurde möglicherweise geändert oder verzögert aber nicht vollständig mit dem richtigen privaten Schlüssel signiert. (Ausnahme von HRESULT: 0x80131045)
   bei Test.Project.Integration.InMemory.Test.Tester.ExecuteTestCase(String testCasePath)
[...]
Calculating coverage result...
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc.Default_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc.Default'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc.Grandfather_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc.Grandfather'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc.Integration_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc.Integration'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc.Integration.Test.Project1_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc.Integration.Test.Project1'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc.Integration.InMemory_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc.Integration.InMemory'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc.Integration.InMemory.Portable_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc.Integration.InMemory.Portable'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc.Persistence_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc.Persistence'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc.Persistence.File_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc.Persistence.File'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc.Persistence.Intermediate.Data_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc.Persistence.Intermediate.Data'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc.Persistence.Intermediate_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc.Persistence.Intermediate'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc.Persistence.Intermediate.Test.Project1_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc.Persistence.Intermediate.Test.Project1'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Alloc.Persistence.Intermediate.Test.Project1.Grandfather_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Alloc.Persistence.Intermediate.Test.Project1.Grandfather'
Hits file:'C:\Users\dev334\AppData\Local\Temp\Test.Project.Util_50a9b389-fe9e-4324-9162-491b437d657a' not found for module: 'Test.Project.Util'

Basically it seems to me, that there is a problem with the path of my assemblies? Has anyone an idea how to solve this issue?

Thanks in advance for your help,

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Aug 20, 2019

seem a dup of #347 can you try solutions?
Another question are you using last version https://www.nuget.org/packages/coverlet.console/?
Also are you signing the assemblies?I don't know german lang but seem that the error is the anti-tampering failure of signed assembly, coverlet instruments dll so if signed .net loader will throw exception.

@MarcoRossignoli MarcoRossignoli added the duplicate This issue or pull request already exists label Aug 20, 2019
@SteveGilham
Copy link

From version 0.11 of Mono.Cecil (released in the last few days), strong naming on write is now supported in the .net core library (as part of a move from .netstandard1.3 to .netstandard2.0) , so it would be possible to thread a strong-name key or keys through the process, to restore the assembly name, presuming that the appropriate ones are available.

Because assembly-named type references appear in so many and varied places, AltCover has supported re-strong-naming in the Framework/Mono built tools since the beginning, and now from v6.0.x has added support in the .net core built tools too.

@MarcoRossignoli
Copy link
Collaborator

You mean re-write with sign with some tmp key?But without original key how does runtime load the libs?You mean also update all metadata for all lib?

@SteveGilham
Copy link

With this sort of behaviour, it has to be the same key that originally strong-named the assembly, as the framework is looking for a type which has that key's thumbprint baked in.

Yes, this means that if you instrument third-party code, you're stuck -- but you probably didn't want to do that in the first place; but wWith code you built yourself, then the key or keys used should be to hand.

The process would be

  • (New) supply .snk file(s) as arguments
  • for each assembly being processed
    • read assembly
    • (New) see which of those files (if any) signed it (match thumbprints)
    • instrument
    • (New) attach any key found above
    • write instrumented assembly to disk

@MarcoRossignoli
Copy link
Collaborator

@StefanKoenigMUC any news?

Feel free to close if no more useful.

@MarcoRossignoli
Copy link
Collaborator

Close for stale discussion, feel free to re-open it needed, thanks @SteveGilham for the idea on possible fix of signed instrumentation, took note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants