Skip to content

dotnet test hangs after completing tests in project #7314

@twdkeule

Description

@twdkeule

Describe the bug

dotnet test gangs after completing tests with MTP/MSTest.Sdk 4.0.2.
Works fine with 3.11.1

Version used

We are using MSTes SDK: <Project Sdk="MSTest.Sdk">

global.json:

    "msbuild-sdks": {
        "MSTest.Sdk": "4.0.2",
        "MSBuild.SDK.SystemWeb" : "4.0.97"
    },
    "test": {
        "runner": "Microsoft.Testing.Platform"
    }
> dotnet --version
9.0.310

Steps To Reproduce

Run dotnet test on a solution with multiple test projets:

> dotnet test solution.sln --configuration Release --tl:off --no-rebuild --no-restore -- --coverage --coverage-output-format cobertura --coverage-settings "C:\_source\kg\ci\code-coverage.xml" --report-trx --results-directory "C:\..\TestResults" --output detailed --diagnostic

Expected behavior

The command runs all 3 test projects in the solution

Actual behavior

The command hangs after executing only 2 projects.

  Kg.Xxxx.Test -> .Test.exe
  Run tests: 'C:\...\Kg.Xxxx.Test\bin\Release\net48\Kg.Xxxx.Test.exe' [net48|x86]
  Passed! - Failed: 0, Passed: 259, Skipped: 14, Total: 273, Duration: 2s 527ms - Kg.Xxxxx.Test.exe (net48|x86)
[command hangs here]
[Ctrl-C]
C:\Users\.....\.nuget\packages\microsoft.testing.platform.msbuild\2.0.2\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(347,5): warning MSB5021: Terminating the task executable "Kg.StickerDetection.Test" and its child processes because the build was canceled. [C
:\....\Kg.Xxxxx.Test\Kg.Xxxxx.Test.csproj]

From the diagnostic files I can see the

Additional context

Note that we use dotnet SDK 9.0.310, not 10.0.x

I took a memory dump of the test runner.
it seems it is stuck on starting the build of the next test project in the solution:

stacktrace
 	[Async] System.Private.CoreLib.dll!Task (int) [Promise]	C#
>	[Async] Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.StartNewBuildRequests(Microsoft.Build.BackEnd.FullyQualifiedBuildRequest[] requests)	Unknown
 	[Async] Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.BuildProjects(string[] projectFiles, Microsoft.Build.Collections.PropertyDictionary<Microsoft.Build.Execution.ProjectPropertyInstance>[] properties, string[] toolsVersions, string[] targets, bool waitForResults, bool skipNonexistentTargets)	Unknown
 	[Async] Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskHost.BuildProjectFilesInParallelAsync(string[] projectFileNames, string[] targetNames, System.Collections.IDictionary[] globalProperties, System.Collections.Generic.IList<string>[] undefineProperties, string[] toolsVersion, bool returnTargetOutputs, bool skipNonexistentTargets)	Unknown
 	[Async] Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskHost.InternalBuildProjects(string[] projectFileNames, string[] targetNames, System.Collections.IDictionary[] globalProperties, System.Collections.Generic.IList<string>[] undefineProperties, string[] toolsVersion, bool returnTargetOutputs, bool skipNonexistentTargets)	Unknown
 	[Async] Microsoft.Build.dll!Microsoft.Build.BackEnd.MSBuild.ExecuteTargets(Microsoft.Build.Framework.ITaskItem[] projects, System.Collections.Generic.Dictionary<string, string> propertiesTable, string[] undefineProperties, System.Collections.Generic.List<string[]> targetLists, bool stopOnFirstFailure, bool rebaseOutputs, Microsoft.Build.Framework.IBuildEngine3 buildEngine, Microsoft.Build.BackEnd.TaskLoggingHelper log, System.Collections.Generic.List<Microsoft.Build.Framework.ITaskItem> targetOutputs, bool unloadProjectsOnCompletion, string toolsVersion, bool skipNonexistentTargets)	Unknown
 	[Async] Microsoft.Build.dll!Microsoft.Build.BackEnd.MSBuild.BuildProjectsInParallel(System.Collections.Generic.Dictionary<string, string> propertiesTable, string[] undefinePropertiesArray, System.Collections.Generic.List<string[]> targetLists, bool success, bool[] skipProjects)	Unknown
 	[Async] Microsoft.Build.dll!Microsoft.Build.BackEnd.MSBuild.ExecuteInternal()	Unknown
 	[Async] Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(Microsoft.Build.BackEnd.TaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask)	Unknown
 	[Async] 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
 	[Async] 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
 	[Async] Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(Microsoft.Build.BackEnd.TaskExecutionMode mode, Microsoft.Build.BackEnd.Lookup lookup)	Unknown
 	[Async] 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
 	[Async] 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
 	[Async] 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
 	[Async] Microsoft.Build.dll!Microsoft.Build.BackEnd.TargetBuilder.ProcessTargetStack(Microsoft.Build.BackEnd.ITaskBuilder taskBuilder)	Unknown
 	[Async] 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 name, Microsoft.Build.Framework.TargetBuiltReason reason)[] targetNames, Microsoft.Build.BackEnd.Lookup baseLookup, System.Threading.CancellationToken cancellationToken)	Unknown
 	[Async] Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.BuildProject()	Unknown
 	[Async] Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.RequestThreadProc(bool setThreadParameters)	Unknown
 	[Async] System.Private.CoreLib.dll!System.Threading.Tasks.Task.Run	C#

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions