altcover
altcover copied to clipboard
ERROR *** Instrumentation phase failed - Failed to resolve assembly: System.Data.Common
Hi,
I am getting this error. Any solution?
- mono Tool_AETool/packages/altcover.8.8.21/tools/net472/AltCover.exe --reportFormat=OpenCover --attributeFilter=ExcludeFromCodeCoverage --linecover -r Tool_AETool/_Reports/coverage.xml --outputDirectory=Tool_AETool/bin/Debug/__Instrumented -i Tool_AETool/bin/Debug --assemblyExcludeFilter=NUnit3.+ --assemblyExcludeFilter=nunit+ --assemblyExcludeFilter=Microsoft+
Creating folder /home/jenkins/agent/workspace/l_AETool_feature_US191919/Tool_AETool/bin/Debug/__Instrumented/ Instrumenting files from /home/jenkins/agent/workspace/l_AETool_feature_US191919/Tool_AETool/bin/Debug/ Writing files to /home/jenkins/agent/workspace/l_AETool_feature_US191919/Tool_AETool/bin/Debug/__Instrumented/ Creating folder /home/jenkins/agent/workspace/l_AETool_feature_US191919/Tool_AETool/_Reports
=> /home/jenkins/agent/workspace/l_AETool_feature_US191919/Tool_AETool/bin/Debug/Dapper.dll => /home/jenkins/agent/workspace/l_AETool_feature_US191919/Tool_AETool/bin/Debug/AE.exe => /home/jenkins/agent/workspace/l_AETool_feature_US191919/Tool_AETool/bin/Debug/NUnit3.TestAdapter.dll => /home/jenkins/agent/workspace/l_AETool_feature_US191919/Tool_AETool/bin/Debug/AETool.Test.dll
Coverage Report: /home/jenkins/agent/workspace/l_AETool_feature_US191919/Tool_AETool/_Reports/coverage.xml
/home/jenkins/agent/workspace/l_AETool_feature_US191919/Tool_AETool/bin/Debug/__Instrumented/NUnit3.TestAdapter.dll
<= NUnit3.TestAdapter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null
/home/jenkins/agent/workspace/l_AETool_feature_US191919/Tool_AETool/bin/Debug/__Instrumented/Dapper.dll
<= Dapper, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
Resolved assembly reference 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' as file '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Data.dll'.
ERROR *** Instrumentation phase failed
Failed to resolve assembly: 'System.Data.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Details written to /home/jenkins/agent/workspace/l_AETool_feature_US191919/Tool_AETool/bin/Debug/__Instrumented/AltCover-2024-04-26--10-11-19.log
script returned exit code 255
If this is a .Net Framework/Mono application then specifying --dependency=/path/to/System.Data.dll
(the path being in the GAC_64 area, on Windows, at least) will override the heuristic for looking up unresolved references that has led down this path, and point the resolution at the correct assembly.
Just for your information...
In my C# .Net Framework v4.8 project, I have installed few packages including Nunit console runner and Dapper. When i build the solution, i am not getting any error but in jenkins (linux environment) while intrumentation i am getting the below error. If i remove any one of this packages, then i am not getting the below error.
ERROR *** Instrumentation phase failed Failed to resolve assembly: 'System.Data.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
In my C# .Net Framework v4.8 project
I expected as much. The underlying issue is Mono.Cecil's need to have a fully resolved type definition before it will write out an assembly that uses that type. It will automatically look for assemblies in the same folder as the one being processed, but otherwise has to be hand held. The resolution heuristic has found the dotnet
version of System.Data.dll
with the appropriate name, but that's just a facade, that says that the type being sought is in some version of System.Data.Common.dll
.
I'm not going to try and guess what the precise environmental quirks are that are causing the differences in behaviour (possibly a VM being instantiated with or without some specific dotnet
installed?), but feeding the instrumentation the System.Data.dll
assembly it needs, either by tweaking the build parameters to get it copied to the build output directory, or by specifying where it can be found via --dependency=
, will prevent the heuristic from making a guess.
I noticed that using older version of altcover not throwing any error.
Failed to resolve assembly System.Data.Common:-
sh "nuget install altcover -o ${Tool}/packages"
I am installing the altcover with the above command. So it is installing latest version of altcover. (version 8.8.21)
mono Tool_AETool/packages/altcover.8.8.21/tools/net472/AltCover.exe --reportFormat=OpenCover --attributeFilter=ExcludeFromCodeCoverage --linecover -r Tool_AETool/_Reports/coverage.xml --outputDirectory=Tool_AETool/bin/Debug/__Instrumented -i Tool_AETool/bin/Debug --assemblyExcludeFilter=NUnit3.+ --assemblyExcludeFilter=nunit+ --assemblyExcludeFilter=Microsoft+
No Error:-
If i install older version using below command. Its working without any issues.
sh "nuget install altcover -o ${Tool}/packages -Version 8.6.95"
mono Tool_AETool/packages/altcover.8.6.95/tools/net472/AltCover.exe --reportFormat=OpenCover --attributeFilter=ExcludeFromCodeCoverage --linecover -r Tool_AETool/_Reports/coverage.xml --outputDirectory=Tool_AETool/bin/Debug/__Instrumented -i Tool_AETool/bin/Debug --assemblyExcludeFilter=NUnit3.+ --assemblyExcludeFilter=nunit+ --assemblyExcludeFilter=Microsoft+
This may simply be another manifestation of the package issue already mentioned, as the different altcover versions involve different dependencies.
The attached is a pre-release which makes a search order for resolving non-local assemblies
- nuget cache
- GAC (incl Mono GAC)
-
dotnet
shared libraries
where Mono GAC includes /usr/lib/mono/gac
and $MONO_GAC_PREFIX/lib/mono/gac
as per https://www.mono-project.com/docs/advanced/assemblies-and-the-gac/ - this should help the heuristic; but at the end of the day just saying where the dependencies are is the only sure fix; and I can't do that, only you can.
Thanks....This helped me to resolved the issue...
In that case, that change is going into the next release.
Released in v8.8.53