Coverlet: InstrumentationTask hangs on run

Created on 12 Feb 2019  路  19Comments  路  Source: coverlet-coverage/coverlet

I have setup Covelet in several solutions gathering up code coverage and reporting them to SonarQube. I'm having trouble with one particular solution and I'm not sure where to begin debugging. I have this simple command:

dotnet test mysolution.tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[xunit.*]*"

For most solutions, this runs just fine in PowerShell and I'm very happy with Coverlet. But on this one, it just hangs once the build is complete. After I break out, then PS starts repeating this warning over and over:

C:\myusersfolder\.nuget\packages\coverlet.msbuild\2.5.1\build\netstandard2.0\coverlet.msbuild.targets(20,5): warning MSB4220: Waiting for the currently executing task "Coverlet.MSbuild.Tasks.InstrumentationTask" to cancel. [C:\Projects\...\mysolution.tests.csproj]

Not sure where to start on debugging this. Any ideas?

Running VS2017, all of these projects are .NET core targeting net462. Can't think of anything about this solution that's different than the ones this works fine on, except that it's a bit larger than the others.

bug

All 19 comments

Have you tried on different machine?
Are you on win?If so you could try to dump follow this guide https://blogs.msdn.microsoft.com/debugger/2009/12/30/what-is-a-dump-and-how-do-i-create-one/ and attach here if not so big and you don't have secrets in your code(or share on onedrive), maybe it's not related to coverlet.
If you want to debug by yourself you can clone coverlet repo and rebuild in debug(default) and on your mysolution.tests.csproj add this msbuild imports https://github.com/tonerdo/coverlet/tree/master/src/coverlet.msbuild similar to https://github.com/MarcoRossignoli/marcorossignoli.github.io/blob/master/src/coverlet/Issue1/test/Keys.Api.Tests/Keys.Api.Tests.csproj#L8 and point your local Tasks, you can add Debugger.Launch() on https://github.com/tonerdo/coverlet/blob/master/src/coverlet.msbuild.tasks/InstrumentationTask.cs#L85 (rebuild coverlet skipping the attach) and after re-run your command and you should be able to attach to instrumentation task to understand where hangs.

@MarcoRossignoli the link
https://github.com/tonerdo/coverlet/tree/master/src/coverlet.msbuild 404 on me.

I'm having the same issue as well with a net47 target framework. I'm going to try and debug locally and if I can find something I will post it

The files have been moved sorry https://github.com/tonerdo/coverlet/tree/master/src/coverlet.msbuild.tasks coverlet.msbuild.props and coverlet.msbuild.targets

So im not sure how this is suppose to work but when coming across the dll net47/win10-x64/Dapper.StrongName.dll

in the Coverage.cs file foreach loop line 90
var result = instrumenter.Instrument();
is where i get into a non responding task.

I have tried to only include my .dll only with /p:Include="[CompanyName.] but then I loose all code coverage in other assemblies

is where i get into a non responding task.

when task hand and if you're in debug(attached) you can click on VS pause button and check all stacks to understand where app hanging https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/viewing-the-call-stack-in-visual-studio you'll see one stack for every thread running.

Thanks Marco for the information.

So I have looked at the Call Stack window after pausing when the task appears to hang, I only see one call stack.

I looked in the Parallel Stack Window as well, and I can only see one thread that is calling the attached code, and it displays the same information as the call stack window

I will first display the call stack that I think will interest you that is related to the github repo I downloaded then the full call stack.

Let me know if there is any more data you will need. I will continue on to see if I can find any more information that may be useful to you.

The module path being tested is

bin\Debug\net47\win10-x64\Dapper.StrongName.dll

Relevant call stack to coverlet

>   coverlet.core.dll!Coverlet.Core.Instrumentation.Instrumenter.InstrumentModule() Line 157    C#
    coverlet.core.dll!Coverlet.Core.Instrumentation.Instrumenter.Instrument() Line 69   C#
    coverlet.core.dll!Coverlet.Core.Coverage.PrepareModules() Line 90   C#
    coverlet.msbuild.tasks.dll!Coverlet.MSbuild.Tasks.InstrumentationTask.Execute() Line 100    C#

Below is the full call stack when paused


    Mono.Cecil.dll!Mono.Cecil.MetadataResolver.GetType(Mono.Cecil.ModuleDefinition module, Mono.Cecil.TypeReference reference)  Unknown
    Mono.Cecil.dll!Mono.Cecil.Mixin.CheckedResolve(Mono.Cecil.TypeReference self)   Unknown
    Mono.Cecil.dll!Mono.Cecil.MetadataBuilder.GetConstantType(Mono.Cecil.TypeReference constant_type, object constant)  Unknown
    Mono.Cecil.dll!Mono.Cecil.MetadataBuilder.AddConstant(Mono.Cecil.IConstantProvider owner, Mono.Cecil.TypeReference type)    Unknown
    Mono.Cecil.dll!Mono.Cecil.MetadataBuilder.AddField(Mono.Cecil.FieldDefinition field)    Unknown
    Mono.Cecil.dll!Mono.Cecil.MetadataBuilder.AddFields(Mono.Cecil.TypeDefinition type) Unknown
    Mono.Cecil.dll!Mono.Cecil.MetadataBuilder.AddType(Mono.Cecil.TypeDefinition type)   Unknown
    Mono.Cecil.dll!Mono.Cecil.MetadataBuilder.AddTypes()    Unknown
    Mono.Cecil.dll!Mono.Cecil.MetadataBuilder.BuildTypes()  Unknown
    Mono.Cecil.dll!Mono.Cecil.MetadataBuilder.BuildModule() Unknown
    Mono.Cecil.dll!Mono.Cecil.MetadataBuilder.BuildMetadata()   Unknown
    Mono.Cecil.dll!Mono.Cecil.ModuleWriter.BuildMetadata.AnonymousMethod__2_0(Mono.Cecil.MetadataBuilder builder, Mono.Cecil.MetadataReader _)  Unknown
    Mono.Cecil.dll!Mono.Cecil.ModuleDefinition.Read<System.__Canon, System.__Canon>(System.__Canon item, System.Func<System.__Canon, Mono.Cecil.MetadataReader, System.__Canon> read)   Unknown
    Mono.Cecil.dll!Mono.Cecil.ModuleWriter.BuildMetadata(Mono.Cecil.ModuleDefinition module, Mono.Cecil.MetadataBuilder metadata)   Unknown
    Mono.Cecil.dll!Mono.Cecil.ModuleWriter.Write(Mono.Cecil.ModuleDefinition module, Mono.Disposable<System.IO.Stream> stream, Mono.Cecil.WriterParameters parameters)  Unknown
    Mono.Cecil.dll!Mono.Cecil.ModuleWriter.WriteModule(Mono.Cecil.ModuleDefinition module, Mono.Disposable<System.IO.Stream> stream, Mono.Cecil.WriterParameters parameters)    Unknown
    Mono.Cecil.dll!Mono.Cecil.ModuleDefinition.Write(System.IO.Stream stream, Mono.Cecil.WriterParameters parameters)   Unknown
>   coverlet.core.dll!Coverlet.Core.Instrumentation.Instrumenter.InstrumentModule() Line 157    C#
    coverlet.core.dll!Coverlet.Core.Instrumentation.Instrumenter.Instrument() Line 69   C#
    coverlet.core.dll!Coverlet.Core.Coverage.PrepareModules() Line 90   C#
    coverlet.msbuild.tasks.dll!Coverlet.MSbuild.Tasks.InstrumentationTask.Execute() Line 100    C#
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()  Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask)  Unknown
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25>(ref Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25 stateMachine)    Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask)  Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.InitializeAndExecuteTask(Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.ItemBucket bucket, System.Collections.Generic.IDictionary<string, string> taskIdentityParameters, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask)    Unknown
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.Build.BackEnd.TaskBuilder.<InitializeAndExecuteTask>d__23>(ref Microsoft.Build.BackEnd.TaskBuilder.<InitializeAndExecuteTask>d__23 stateMachine)  Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.InitializeAndExecuteTask(Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.ItemBucket bucket, System.Collections.Generic.IDictionary<string, string> taskIdentityParameters, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask)    Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.ExecuteBucket(Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask, System.Collections.Generic.Dictionary<string, string> lookupHash)   Unknown
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.Build.BackEnd.TaskBuilder.<ExecuteBucket>d__19>(ref Microsoft.Build.BackEnd.TaskBuilder.<ExecuteBucket>d__19 stateMachine)    Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.ExecuteBucket(Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask, System.Collections.Generic.Dictionary<string, string> lookupHash)   Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(Microsoft.Build.BackEnd.TaskExecutionMode mode, Microsoft.Build.BackEnd.Lookup lookup)  Unknown
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__18>(ref Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__18 stateMachine)    Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(Microsoft.Build.BackEnd.TaskExecutionMode mode, Microsoft.Build.BackEnd.Lookup lookup)  Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(Microsoft.Build.BackEnd.Logging.TargetLoggingContext loggingContext, Microsoft.Build.BackEnd.BuildRequestEntry requestEntry, Microsoft.Build.BackEnd.ITargetBuilderCallback targetBuilderCallback, Microsoft.Build.Execution.ProjectTargetInstanceChild taskInstance, Microsoft.Build.BackEnd.TaskExecutionMode mode, Microsoft.Build.BackEnd.Lookup inferLookup, Microsoft.Build.BackEnd.Lookup executeLookup, System.Threading.CancellationToken cancellationToken)   Unknown
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__13>(ref Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__13 stateMachine)    Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(Microsoft.Build.BackEnd.Logging.TargetLoggingContext loggingContext, Microsoft.Build.BackEnd.BuildRequestEntry requestEntry, Microsoft.Build.BackEnd.ITargetBuilderCallback targetBuilderCallback, Microsoft.Build.Execution.ProjectTargetInstanceChild taskInstance, Microsoft.Build.BackEnd.TaskExecutionMode mode, Microsoft.Build.BackEnd.Lookup inferLookup, Microsoft.Build.BackEnd.Lookup executeLookup, System.Threading.CancellationToken cancellationToken)   Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TargetEntry.ProcessBucket(Microsoft.Build.BackEnd.ITaskBuilder taskBuilder, Microsoft.Build.BackEnd.Logging.TargetLoggingContext targetLoggingContext, Microsoft.Build.BackEnd.TaskExecutionMode mode, Microsoft.Build.BackEnd.Lookup lookupForInference, Microsoft.Build.BackEnd.Lookup lookupForExecution)    Unknown
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.Build.BackEnd.TargetEntry.<ProcessBucket>d__52>(ref Microsoft.Build.BackEnd.TargetEntry.<ProcessBucket>d__52 stateMachine)    Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TargetEntry.ProcessBucket(Microsoft.Build.BackEnd.ITaskBuilder taskBuilder, Microsoft.Build.BackEnd.Logging.TargetLoggingContext targetLoggingContext, Microsoft.Build.BackEnd.TaskExecutionMode mode, Microsoft.Build.BackEnd.Lookup lookupForInference, Microsoft.Build.BackEnd.Lookup lookupForExecution)    Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TargetEntry.ExecuteTarget(Microsoft.Build.BackEnd.ITaskBuilder taskBuilder, Microsoft.Build.BackEnd.BuildRequestEntry requestEntry, Microsoft.Build.BackEnd.Logging.ProjectLoggingContext projectLoggingContext, System.Threading.CancellationToken cancellationToken)  Unknown
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.Build.BackEnd.TargetEntry.<ExecuteTarget>d__45>(ref Microsoft.Build.BackEnd.TargetEntry.<ExecuteTarget>d__45 stateMachine)    Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TargetEntry.ExecuteTarget(Microsoft.Build.BackEnd.ITaskBuilder taskBuilder, Microsoft.Build.BackEnd.BuildRequestEntry requestEntry, Microsoft.Build.BackEnd.Logging.ProjectLoggingContext projectLoggingContext, System.Threading.CancellationToken cancellationToken)  Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TargetBuilder.ProcessTargetStack(Microsoft.Build.BackEnd.ITaskBuilder taskBuilder)  Unknown
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.Build.BackEnd.TargetBuilder.<ProcessTargetStack>d__21>(ref Microsoft.Build.BackEnd.TargetBuilder.<ProcessTargetStack>d__21 stateMachine)  Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TargetBuilder.ProcessTargetStack(Microsoft.Build.BackEnd.ITaskBuilder taskBuilder)  Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TargetBuilder.BuildTargets(Microsoft.Build.BackEnd.Logging.ProjectLoggingContext loggingContext, Microsoft.Build.BackEnd.BuildRequestEntry entry, Microsoft.Build.BackEnd.IRequestBuilderCallback callback, string[] targetNames, Microsoft.Build.BackEnd.Lookup baseLookup, System.Threading.CancellationToken cancellationToken)  Unknown
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.Build.BackEnd.TargetBuilder.<BuildTargets>d__10>(ref Microsoft.Build.BackEnd.TargetBuilder.<BuildTargets>d__10 stateMachine)  Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.TargetBuilder.BuildTargets(Microsoft.Build.BackEnd.Logging.ProjectLoggingContext loggingContext, Microsoft.Build.BackEnd.BuildRequestEntry entry, Microsoft.Build.BackEnd.IRequestBuilderCallback callback, string[] targetNames, Microsoft.Build.BackEnd.Lookup baseLookup, System.Threading.CancellationToken cancellationToken)  Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.BuildProject()   Unknown
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.Build.BackEnd.RequestBuilder.<BuildProject>d__58>(ref Microsoft.Build.BackEnd.RequestBuilder.<BuildProject>d__58 stateMachine)    Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.BuildProject()   Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.BuildAndReport() Unknown
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.Build.BackEnd.RequestBuilder.<BuildAndReport>d__50>(ref Microsoft.Build.BackEnd.RequestBuilder.<BuildAndReport>d__50 stateMachine)    Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.BuildAndReport() Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.RequestThreadProc(bool setThreadParameters)  Unknown
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.Build.BackEnd.RequestBuilder.<RequestThreadProc>d__49>(ref Microsoft.Build.BackEnd.RequestBuilder.<RequestThreadProc>d__49 stateMachine)  Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.RequestThreadProc(bool setThreadParameters)  Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.StartBuilderThread.AnonymousMethod__45_2()   Unknown
    System.Private.CoreLib.dll!System.Threading.Tasks.Task<System.Threading.Tasks.Task>.InnerInvoke()   Unknown
    System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)   Unknown
    System.Private.CoreLib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot)  Unknown
    System.Private.CoreLib.dll!System.Threading.Tasks.Task.ExecuteEntry()   Unknown
    Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.DedicatedThreadsTaskScheduler.InjectThread.AnonymousMethod__6_0()    Unknown
    System.Threading.Thread.dll!System.Threading.Thread.ThreadMain_ThreadStart()    Unknown
    System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)   Unknown

I forgot to add. My code is hanged on line 157 of Instrumenter.cs

module.Write(stream, new WriterParameters { WriteSymbols = true });

Dont spin your wheels too much on this information. I tried to pause again and visual studio is throwing an exception. I'm going to try and replicate the issue after lunch and see if I can pull the module path out when I get exception pausing

Dont spin your wheels too much on this information. I tried to pause again and visual studio is throwing an exception. I'm going to try and replicate the issue after lunch and see if I can pull the module path out when I get exception pausing

Could you also enable logging(new capabilities) to understand where code hang(before/after instrumentation for instance)

Run dotnet test(verbosity:normal)

... /v:n

and add some logging inside your clone similar to https://github.com/tonerdo/coverlet/blob/f4aa25948df26408e8c1261d6bf93ae08c0d7a9c/src/coverlet.core/Coverage.cs#L78

I keep getting the following

Unable to instrument module {name of project referenced in test project } because No name stream {name of test project }

Writting Module {name of test project } <--- this is my custom log to get the module that is attempting to be written out in Instrumenter.cs line 157

                    _logger.LogInformation($"Writing Module: '{module.Assembly.FullName}'");
                    module.Write(stream, new WriterParameters { WriteSymbols = true });

Instrumented module {name of test project .dll }
Writting module 'Dapper.StrongName

Then when I try to pause I get the following error in a pop up window

The target process exited with code -2146233082 while evaluating the functions 'Mono.Cecil.ModuleReference.ToString'

Alright this may be more useful. I delete my bin and object folder in the test project that was giving me issue and rebuilt my project.

Now pausing the coverlet to the the dialog pop up of

The target process exited with code -2146233082 while evaluating the functions 'Mono.Cecil.ModuleReference.ToString'

will now output the error in powershell for dotnet test

error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.1.504\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.


         MSBUILD : error MSB4166: Child node "3" exited prematurely. Shutting down. Diagnostic information may be found in files in "C:\Users\A750501\AppData\Local\Temp\" and will be named MSBuild_*.failure.txt. This location can be changed by setting the MSBUILDDEBUGPATH environment variable to a different directory.

For some reason

dotnet test --no-build {solution path} -l trx -r {test result folder path} --filter Category!=Integration /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /v:n

is causing my .sqlproj to be built.

I think I'm getting closer to the root issue at hand

At the moment run Coverlet on sln is not supported, could you try to run test for every csproj?

Sure. I start hitting the test project in question and I was getting the same hanging issue.

So I decided to clone the Mono.Cecil repo and add in the references to the coverlet solution .

I have been trying to get the output to be the same without injecting my clone of the coverlet repo but using the clone repo of coverlet, my dotnet test command wants to include my test project. Not sure why that is.

I also started to notice this thing called the hits file. I would sometimes get the error hits file not found, when using my coverlet and Cecil clone repos.

So I decided to remove the injection of the clone repo for coverlet and I have noticed that my hits files are not being created. perhaps that has something to do with it ?

The thing is I cant seem to find where the hits file are created in the coverlet repo. It must be something that mono.Cecil is doing.

Hits file not found is related to another open issue...but I wonder why it hang(seem unrelated to hit file issue)...have you tried to run on different machine?Maybe process dump during hang could be useful also.

sure ill give that a try as well.

I also attempted the test run on my build server and its currently hanging. Perhaps I will try and repo the issue without company code in a little bit, I dont seem to be making much headway.

I have isolated the issue and created a Repo that you should be able to copy on your machine. I'm running windows 10 and have not tested on other machines besides window 10 machines

https://github.com/Frankwayne/BreakCoverletMono

here is the command I'm using to cause the hanging issue.

dotnet test --no-build -l trx --filter Category!=Integration /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /v:n /p:Exclude="[Dapper]"

I believe the issue actually lies in the Mono.Cecil project but I know nothing about those api's and I have used up too much of my time trying to find the issue. If I'm able to work around the issue. I will post how I worked around my issue in another comment.

+++ info if anyone wants to follow my process of tracking down the troublesome code +++

So I can actually get a stackover flow exception with my main project when using a clone of coverlet, mono.cecil. To clone coverlet and mono though you need to remove the nuget references of mono.cecil in the coverlet.core.

Then you have to clone Mono.Cecil. Add in the projects

Mono.Cecil
Mono.Cecil.Mdb
Mono.Cecil.Pdb
Mono.Cecil.Rocks

to the coverlet solution. Then you have to add all 4 references of the Cecil projects to coverlet.core. You would think you only need to add Mono.Cecil and Mono.Cecil.Rocks but you would be wrong as there is some sort of Dependency Injection going on that I wasn't able or want to track down. There are classes in the Mdb and Pdb that Mono.Cecil needs to work correctly.

Then add in the coverlet task injections into your project file that Marco gave above and add in the Debug.Launch statement that he also mentions.

You should be ready to fire off your dotnet test command, and start to hunt your issue down for isolation.

You may have to keep deleting your test project /bin and /obj files though as for some reason if I reused a previous build /bin and /obj files I could not repo the issue. It appears only the first run on newly created binaries would reproduce the issue for me. I have no idea why this is and may be internal thing for Mono or coverlet. I could not determine which was causing this behavior.

To fix my issue I had to remove the default storeName in the method call

public static X509Certificate2 DoSomething(StoreName storeName = StoreName.My)

to

public static X509Certificate2 DoSomething(StoreName storeName)

Thank's for throubleshooting, I'll take a look!

Was this page helpful?
0 / 5 - 0 ratings