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

The provided manager was not found in any slot. #4469

Closed
nohwnd opened this issue May 22, 2023 · 49 comments
Closed

The provided manager was not found in any slot. #4469

nohwnd opened this issue May 22, 2023 · 49 comments
Assignees
Labels

Comments

@nohwnd
Copy link
Member

nohwnd commented May 22, 2023

I'm having a similar issue, and the build fails with the following trace running in Azure Devops hosted agents:

##[error]DiscoveryMessage : System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)

The issue started when moving from 17.5 to 17.6 two days ago.

Originally posted by @jeromelaban in #4467 (comment)

Update: To clarify this issue for future implementation of a fix. When testhost crashes in initialization, we don't communicate back that initialization did not happen and try to continue to the next step, which again does initialization and fails again. This will trigger cleanup 2 times via CompletedRun event, which cleans slots and pushes next work to be executed. First the cleanup will succeed, but the second one will fail. This also highlights that there is a disconnect between the work being done, and when we think the work already completed.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage This item should be discussed in the next triage meeting. label May 22, 2023
@nohwnd
Copy link
Member Author

nohwnd commented May 22, 2023

@jeromelaban Could you please tell me more about how you run your tests (e.g. dotnet test, vstest.console, vstest task, classical / yaml pipeline)?

And what is in your solution, are you multi targetting? Are you running in parallel?

@nohwnd nohwnd self-assigned this May 22, 2023
@PeterHevesi
Copy link

I am experiencing the same problem, but I am not using Azure Devops, but I also switched to VS version 17.6.0, so it is related to new VS version

@nohwnd
Copy link
Member Author

nohwnd commented May 23, 2023

@PeterHevesi do you have some more details on how to repro this please?

@PeterHevesi
Copy link

Sorry, no I don't and I would explore it further to tell you, but I don't have time, I am very busy now, so I am rather downgrading to VS 17.5

@nohwnd
Copy link
Member Author

nohwnd commented May 23, 2023

Totally understandable. Thanks for getting back to me.

@jeromelaban
Copy link

@jeromelaban Could you please tell me more about how you run your tests (e.g. dotnet test, vstest.console, vstest task, classical / yaml pipeline)?
And what is in your solution, are you multi targetting? Are you running in parallel?

Thanks for taking a look into this. This is our CI step, and we're using net7.0 and net8.0 binaries.

Here's a larger build log, if that can help.

@nohwnd
Copy link
Member Author

nohwnd commented May 24, 2023

Okay, thanks, looks like it is in fact related to #4467 and a workaround for you would be to provide dll filter that is specific to your test project naming pattern. It seems that most your projects are named Tests..dll
something, that should restrict your pattern better than using test.dll:

So I would try replacing this line, with bin/**/*Tests*.dll, and keeping the rest of the exclude rules in place for now to see if it helped.

https://github.com/unoplatform/uno/blob/master/build/ci/.azure-devops-unit-tests.yml#L77

@PeterHevesi
Copy link

PeterHevesi commented May 25, 2023

@nohwnd , Hi, so now I have some more time, so I will tell you my setup:
I was using latest Visual Studio 17.6.1 with latest NUnit 3.13.3, NUnit3TestAdapter 4.4.2 and latest Microsoft Playwright 1.33.0
I have latest Microsoft.NET.Test.Sdk 17.6.0 and latest Microsoft.TestPlatform.TestHost 17.6.0
I am using .NET 7 and C# 11
(But because I already downgraded to 17.5.5, and won't upgrade until this will fixed, I can't try to reproduce it again)
(But please ask for any other info that may help you)

And so, are you working on fixing this? How it is going? When do you expect it to be fixed?

@Evangelink
Copy link
Member

@nohwnd will give a more detailed explanation but the fix is already merged (see #4474) and we are working on rolling it out to NuGet, VS and .NET.

@nohwnd
Copy link
Member Author

nohwnd commented May 25, 2023

@PeterHevesi I still have not been able to repro this, the related Fix that Amaury mentions might help to fix this. But until I came up with a repro I can't comment on what exactly is going on. Once we have a fix we will roll it out to nuget, and insert into dotnet sdk and VS, as we will be doing with 17.6.1 that has fix fir #4474

@nohwnd
Copy link
Member Author

nohwnd commented May 26, 2023

@jeromelaban looking at your build log (reposted below in case the build gets removed). There are several errors that prevent testhost from starting/running. The error The provided manager was not found in any slot. is a consequence of testhost exiting early, I am not yet sure why we cannot find the manager in the slot, but solving this won't solve your issues. Your testhosts will still crash.

I see two types of errors:

Testhost process for source(s) 'D:\a\1\s\src\Build\Tests\bin\Release_AnyCPU\net7.0\Uno.Analyzers.Tests.dll' exited with error: Error:
An assembly specified in the application dependencies manifest (Uno.Analyzers.Tests.deps.json) was not found:
package: 'DiffPlex', version: '1.5.0'
path: 'lib/netstandard1.0/DiffPlex.dll'

There is a dependency in manifest that is not found so the process cannot start.

And

Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibrary.dll' exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\hostedtoolcache\windows\dotnet'.
Failed to run as a self-contained app.

  • The application was run as a self-contained app because 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' was not found.
  • If this should be a framework-dependent app, add the 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' file and specify the appropriate framework.

I can repro with running just in command line.

dotnet test src\Build\Tests\bin\Release_AnyCPU\net7.0\Uno.Analyzers.Tests.dll.

##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests.ViewLibrary\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibrary.dll' exited with error: Error:
  An assembly specified in the application dependencies manifest (Uno.UI.Tests.ViewLibrary.deps.json) was not found:
    package: 'Microsoft.Extensions.Configuration', version: '5.0.0'
    path: 'lib/netstandard2.0/Microsoft.Extensions.Configuration.dll'
. Please check the diagnostic logs for more information.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests.ViewLibrary\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibrary.dll' exited with error: . Please check the diagnostic logs for more information.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
##[error]DiscoveryMessage : System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibrary.dll' exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\hostedtoolcache\windows\dotnet'.
Failed to run as a self-contained app.
  - The application was run as a self-contained app because 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' was not found.
  - If this should be a framework-dependent app, add the 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' file and specify the appropriate framework.
. Please check the diagnostic logs for more information.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibrary.dll' exited with error: . Please check the diagnostic logs for more information.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibraryProps.dll' exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\hostedtoolcache\windows\dotnet'.
Failed to run as a self-contained app.
  - The application was run as a self-contained app because 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' was not found.
  - If this should be a framework-dependent app, add the 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' file and specify the appropriate framework.
. Please check the diagnostic logs for more information.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
Number of testcases discovered : 0
Discovered tests 0 from sources
=================================================================
##[error]The slice of type 'Discovery' is 'Aborted' because of the error : System.Exception: Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibraryProps.dll' exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\hostedtoolcache\windows\dotnet'.
Failed to run as a self-contained app.
  - The application was run as a self-contained app because 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' was not found.
  - If this should be a framework-dependent app, add the 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' file and specify the appropriate framework.
. Please check the diagnostic logs for more information.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
Received the command : Stop

@nohwnd
Copy link
Member Author

nohwnd commented May 26, 2023

Additionally, did you move some of the projects from .NET Framework .NET? At least the one I was looking at is not referencing Microsoft.NET.Test.SDK, which will make it fallback on a fallback of test.sdk that is shipped with the console, and that might be imcompatible with the project, or broken in other ways because we are doing some assumptions there that might not be true.

Edit: Adding that reference to the Uno.Analyzers.Tests project makes it run the tests in my console.

@jeromelaban
Copy link

@nohwnd Indeed, we moved some of the tests to .NET 7, in an upcoming branch (that's where the tests fail). The analyzer tests are not super fancy, though they depend on Roslyn, so maybe that's one of the source for the dependency issue?

I'll add the reference and see if it helps on my end as well! Thanks for the troubleshooting!

@nohwnd
Copy link
Member Author

nohwnd commented May 26, 2023

I've also finally found the underlying issue with not finding the manager in slot.

    private void StartTestRunOnConcurrentManager(
        IProxyExecutionManager proxyExecutionManager,
        IInternalTestRunEventsHandler eventHandler,
        TestRunCriteria testRunCriteria,
        bool initialized,
        Task? initTask)
    {
        if (testRunCriteria != null)
        {
            Task.Run(() =>
                {
                    if (!initialized)
                    {
                        if (!proxyExecutionManager.IsInitialized)
                        {
                            proxyExecutionManager.Initialize(_skipDefaultAdapters);
                        }

                        Interlocked.Increment(ref _runStartedClients);
                        proxyExecutionManager.InitializeTestRun(testRunCriteria, eventHandler);
                    }
                    else
                    {
                        initTask!.Wait();
                    }

                    EqtTrace.Verbose("ParallelProxyExecutionManager: Execution started. Started clients: " + _runStartedClients);

                    proxyExecutionManager.StartTestRun(testRunCriteria, eventHandler);
                })

This code kicks off work on each testhost that we start in parallel (which we also use when we pre-start testhost).

proxyExecutionManager.InitializeTestRun(testRunCriteria, eventHandler); attempts to start testhost process, and fails. Of course it does not throw an exception but instead it emits RunCompletedEvent, which is handled by the rest of the code and propagates back to the parallel handler, which grabs the slot that is holding the failed manager and clears it.

The method returns void, and because it does not throw we dont't know that the initialization failed, and continue executing. We again attempt to start testhost, because proxyExecutionManager.StartTestRun(testRunCriteria, eventHandler); again checks if testhost is initialized and if not it tries to start it up. We fail again, and again trigger the error handler that tries to clean up the slot. This time it won't find it of course because the slot is already cleared and possible re-purposed for a different manager.

On thing that threw me off was that the stacks look very similar in both places, so I did not notice that in one case we go directly into Initialize and in another we go into Start and then Initialize, even thought I was specifically thinking about that possibility, but did not compare the stacks in a diff tool unfortunately. That could have saved me half a day.

image

If you ask why it worked in the past, that is because previously we did not use those slots and just ignored any double event notifications because the "testhost is dead anyway".

In any case this is not a serious issue, as it can be reached only when the testhost already failed to start up.

@nohwnd nohwnd added bug and removed needs-triage This item should be discussed in the next triage meeting. labels May 26, 2023
@jeromelaban
Copy link

Thanks for the analysis! I can confirm that adding the missing package reference is fixing the issue.

@PeterHevesi
Copy link

So what is the current state of this bug?
What package reference do you mean @jeromelaban ?

@jeromelaban
Copy link

@PeterHevesi I added a reference to Microsoft.NET.Test.SDK.

@nohwnd
Copy link
Member Author

nohwnd commented Jun 1, 2023

@PeterHevesi 17.6.1 was released today with the fix for the other problem, which can under some circumstances fix this problem as well. This problem is only happening after crash of testhost (based on the provided repro), the testhost crash needs to be solved, as this is just a by-product of that crash.

Why specifically it crashes in your case with 17.6.0 but not 17.5.0 I don't know, because I don't have a repro from you unfortunately.

@mstv
Copy link

mstv commented Jun 13, 2023

Test discovery and execution fails in Visual Studio, too (tested with 17.6.2 and 17.6.3).

image

========== Starting test discovery ==========
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()<---

NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
========== Test discovery aborted: 448 Tests found in 1,1 sec ==========
Starting test discovery for requested test run
========== Starting test discovery ==========
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()<---

========== Test discovery aborted: 0 Tests found in 15 ms ==========
========== Starting test run ==========
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\IntegrationTests\BugReporter.IntegrationTests\net6.0-windows\BugReporter.IntegrationTests.dll
   NUnit3TestExecutor discovered 1 of 1 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\BugReporter.Tests\net6.0-windows\BugReporter.Tests.dll
   NUnit3TestExecutor discovered 14 of 14 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\GitExtUtils.Tests\net6.0-windows\GitExtUtils.Tests.dll
   NUnit3TestExecutor discovered 260 of 260 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\AppVeyorIntegration.Tests\net6.0-windows\AppVeyorIntegration.Tests.dll
   NUnit3TestExecutor discovered 3 of 3 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\AzureDevOpsIntegration.Tests\net6.0-windows\AzureDevOpsIntegration.Tests.dll
   NUnit3TestExecutor discovered 48 of 48 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\ReleaseNotesGenerator.Tests\net6.0-windows\ReleaseNotesGenerator.Tests.dll
   NUnit3TestExecutor discovered 13 of 13 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\GitUIPluginInterfaces.Tests\net6.0-windows\GitUIPluginInterfaces.Tests.dll
   NUnit3TestExecutor discovered 27 of 27 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\ResourceManager.Tests\net6.0-windows\ResourceManager.Tests.dll
   NUnit3TestExecutor discovered 78 of 78 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\DeleteUnusedBranches.Tests\net6.0-windows\DeleteUnusedBranches.Tests.dll
   NUnit3TestExecutor discovered 4 of 4 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
========== Test run finished: 448 Tests (448 Passed, 0 Failed, 0 Skipped) run in 2 sec ==========

@nohwnd
Copy link
Member Author

nohwnd commented Jun 14, 2023

The currently released version of VS 17.6.3 does not have the fix yet unfortunately, it will be in 17.6.4 that should ship in few days I hope.

@mstv
Copy link

mstv commented Jun 20, 2023

The behavior with 17.6.4 is exactly the same (on my Ryzen 5700U with 16 virtual cores).

@PeterHevesi
Copy link

Yeah the error is still there in 17.6.4, altough from 17.6.3 I think, tests discovery works for me, so I can use it without any problem, it's just that I still see that error

@RevenantBob
Copy link

RevenantBob commented Jun 21, 2023

I just ran into this issue as well in 17.6.4. I always had the reference to Microsoft.NET.Test.SDK in the project.

Tests run fine with dotnet test on command line, but the Test UI fails.

System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()<---
   

@mgexo
Copy link

mgexo commented Jun 22, 2023

We have the same problem too when using .NET6 but NOT when using .NET48
In both cases we use in the .csproj :

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />    
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />

[22/06/2023 2:57:35.978 pm] [Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
[22/06/2023 2:57:35.986 pm] [Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
[22/06/2023 2:57:36.018 pm] [Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
[22/06/2023 2:57:36.022 pm] [Error] System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
[22/06/2023 2:57:36.030 pm] [Error] System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()<---

[22/06/2023 2:57:36.031 pm] [Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
[22/06/2023 2:57:36.038 pm] [Error] System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
[22/06/2023 2:57:36.046 pm] [Error] System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()<---

[22/06/2023 2:57:36.049 pm]  ========== Test discovery aborted: 0 Tests found in 127,4 ms ==========

@mgexo
Copy link

mgexo commented Jun 22, 2023

The worst thing is, that it ends with "Test discovery aborted" instead of continuing with the other .dlls or other assemblies i.e. you have randomly missing tests even though maybe only one .dll has an issue

@mstv
Copy link

mstv commented Jun 24, 2023

A (Re-)Discover button would help. Or is there a way to trigger the discovery manually?

@mgexo
Copy link

mgexo commented Jun 24, 2023

A (Re-)Discover button would help. Or is there a way to trigger the discovery manually?

In Visual Studio Log/Output Window you can switch to the "Tests" Tab. You can see that it is always running the test discovery when you build a project. It even does the test discovery for all projects, not only the one that you build. So, triggering the test-discovery can be simply done by building (even if the build does nothing because all is build and just finishes right away)

That also means that we are now spammed with these errors and exceptions (mentioned above) in the background on each build...

@SimonIpf
Copy link

This started happening in one of our solutions. I was at 17.6.4.
I've completely uninstalled VS2022 and .NET 6 and reinstalled 17.5.5 and the problem still persists.

@jrbye
Copy link

jrbye commented Jun 27, 2023

This started happening in one of our solutions. I was at 17.6.4. I've completely uninstalled VS2022 and .NET 6 and reinstalled 17.5.5 and the problem still persists.

I had to downgrade to 17.5.4 to get rid of the issue.

@RevenantBob
Copy link

Is this issue still going to be present in 17.7?

@SimonIpf
Copy link

@rjbye - Thanks; I just tried this and still have the issue in 17.5.4

@PeterHevesi
Copy link

@nohwnd Did you fix something about this problem in Microsoft.TestPlatform.TestHost 17.6.3 ?

@nohwnd
Copy link
Member Author

nohwnd commented Jun 28, 2023

Yes there are fixes in TP 17.6.2 and 17.6.3, that are inserted into VS 17.6.4.v v17.6.1...v17.6.3

@mstv
Copy link

mstv commented Jun 28, 2023

Thank you, @MarcoRossignoli and @nohwnd! It works as proposed to mark all projects which reference nUnit package but do not contain test cases:

+
+    <!-- Exclude this project from the list of tests project -->
+    <TestProject>false</TestProject>
+    <IsTestProject>false</IsTestProject>
   </PropertyGroup>
 
   <ItemGroup>
@@ -22,4 +27,9 @@
     <PackageReference Include="JetBrains.Annotations" />
   </ItemGroup>
 
+  <ItemGroup>
+    <!-- This project takes depedency on nUnit that adds the TestContainer capability importing NUnit.props, but this is not a test project -->
+    <ProjectCapability Remove="TestContainer" />
+  </ItemGroup>
+
 </Project>

@mgexo
Copy link

mgexo commented Jun 29, 2023

+
+    <!-- Exclude this project from the list of tests project -->
+    <TestProject>false</TestProject>
+    <IsTestProject>false</IsTestProject>
   </PropertyGroup>

Thanks! This also solved the problem for us regarding exceptions but in our case we added it into .vcxproj files of Managed C++ for .NET6 which seemed to cause the Exceptions that I pasted above.

Moreover, we increased the version numbers of the test adapters according to this blog https://www.damirscorner.com/blog/posts/20230616-MinimumMsTestVersionsForVs176.html

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.4" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.4" />

That may help others too

@RevenantBob
Copy link

So is the issue that projects which aren't test projects need to be marked as such?

@PeterHevesi
Copy link

PeterHevesi commented Jun 30, 2023

Yeah, I can confirm. I run latest VS and I have latest version of all those 3 NuGet packages, I marked non testing project as @mstv said, and now I don't have any exception :)
Thanks a lot @nohwnd !!!

@nohwnd
Copy link
Member Author

nohwnd commented Jun 30, 2023

Uuuf. :) I saw just the first part of your message in preview on my phone, and was hoping that this is not another " Can confirm, this is broken for me as well"..

@RevenantBob
Copy link

RevenantBob commented Aug 30, 2023

Followed above advice for skipping projects without tests and updating nuget packages. it went from 19 errors to 2. Problem is I can't figure out the offending projects.

Any way to figure out which project it's trying to load as a test and failing?

@nohwnd
Copy link
Member Author

nohwnd commented Sep 1, 2023

If you run it with --diag:logs\log.txt you should be able to see more info in log.txt log file. There it should say which file it is processing.

@Aero9999
Copy link

Thank you, @MarcoRossignoli and @nohwnd! It works as proposed to mark all projects which reference nUnit package but do not contain test cases:

+    <!-- Exclude this project from the list of tests project -->
+    <TestProject>false</TestProject>
+    <IsTestProject>false</IsTestProject>

Thank you! Been pulling my hair out for the last day. I have both NET6 and Framework and 'Microsoft Unit Testing Framework for C++' tests in my solution and this issue has been a real problem

@jrbye
Copy link

jrbye commented Nov 14, 2023

Is this issue still awaiting a fix or is the fix to mark the offending projects TestProject False? I only have one project that doesn't contain tests and I have marked it and am still experiencing the same issue. I am on .Net 7.0 and have the latest version of the NUnit packages.

It looks like the same issue other people are having. It looks like we are getting all of our tests because it is failing on that one project. We have frozen our Visual Studio at 17.5.4 until we know that this is fixed.

Here are the logs just to confirm this is the same issue. If it isn't then I will do some more searching.

========== Starting test discovery ========== Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable1 sources, IDictionary2 environmentVariables, TestRunnerConnectionInfo connectionInfo) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable1 sources, String runSettings)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
========== Test discovery aborted: 0 Tests found in 559.1 ms ==========
========== Starting test discovery ==========
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable1 sources, IDictionary2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable1 sources, String runSettings) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) ========== Test discovery aborted: 0 Tests found in 20.8 ms ========== ========== Starting test discovery ========== Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable1 sources, IDictionary2 environmentVariables, TestRunnerConnectionInfo connectionInfo) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable1 sources, String runSettings)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
========== Test discovery aborted: 0 Tests found in 7.1 ms ==========
========== Starting test discovery ==========
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable1 sources, IDictionary2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable1 sources, String runSettings) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) ========== Test discovery aborted: 0 Tests found in 8.2 ms ========== ========== Starting test discovery ========== Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable1 sources, IDictionary2 environmentVariables, TestRunnerConnectionInfo connectionInfo) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable1 sources, String runSettings)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
NUnit Adapter 4.5.0.0: Test discovery starting
NUnit Adapter 4.5.0.0: Test discovery starting
NUnit Adapter 4.5.0.0: Test discovery starting
NUnit Adapter 4.5.0.0: Test discovery starting
NUnit Adapter 4.5.0.0: Test discovery starting
NUnit Adapter 4.5.0.0: Test discovery complete
NUnit Adapter 4.5.0.0: Test discovery complete
NUnit Adapter 4.5.0.0: Test discovery complete
NUnit Adapter 4.5.0.0: Test discovery complete
NUnit Adapter 4.5.0.0: Test discovery complete
========== Test discovery aborted: 830 Tests found in 1.4 sec ==========
`

@nohwnd
Copy link
Member Author

nohwnd commented Nov 14, 2023

is the fix to mark the offending projects TestProject False?

^^^ this

@jrbye
Copy link

jrbye commented Nov 14, 2023

is the fix to mark the offending projects TestProject False?

^^^ this

This isn't working for me. I am on VS 17.5.4. Do I need to upgrade or is there something else I can check or another place I should be setting this rather than the project file?

@nohwnd
Copy link
Member Author

nohwnd commented Nov 14, 2023

Try adding this item group to your project.

  <ItemGroup>
    <ProjectCapability Remove="TestContainer" />
  </ItemGroup>

@jrbye
Copy link

jrbye commented Nov 14, 2023

Try adding this item group to your project.

  <ItemGroup>
    <ProjectCapability Remove="TestContainer" />
  </ItemGroup>

This worked! For whatever reason I had to remove and add back the dependencies of my projects to this project after doing this but now I am getting no failures. Thank you @nohwnd.

@nohwnd
Copy link
Member Author

nohwnd commented Jul 10, 2024

As mentioned here, this issue would not prevent the testhost from crashing, it happens after, and so it is not severe enough to fix.

#4469 (comment)

@nohwnd nohwnd closed this as completed Jul 10, 2024
@IanKemp
Copy link

IanKemp commented Jul 31, 2024

Seeing this again in VS 17.10.5 with NUnit and .NET 8.0 - guessing there has been a regression somewhere.

Yes, I have a reference to Microsoft.NET.Test.Sdk (latest version 17.10.0) in all my test projects.
No, I do not have a reference to NUnit in any non-test projects.

@nohwnd
Copy link
Member Author

nohwnd commented Aug 5, 2024

Could you please start a new issue and post a repro if you have one?

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

No branches or pull requests