Vstest: Unable to run NUnit unit test. 'Unable to find testhost.dll Please publish your test project and retry.'

Created on 12 Dec 2018  路  18Comments  路  Source: microsoft/vstest

Description

Unable to run NUnit unit test. 'Unable to find testhost.dll Please publish your test project and retry.'

Diagnostic logs

[12/12/2018 8:33:52 AM Informational] ------ Discover test started ------
[12/12/2018 8:33:54 AM Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostPath(String runtimeConfigDevPath, String depsFilePath, String sourceDirectory)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable1 sources, IDictionary2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable1 sources) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) [12/12/2018 8:33:55 AM Warning] No test is available in F:\Projects\Foundation\Foundation.Core\Foundation.Common.Unity\bin\Debug\netstandard2.0\Foundation.Common.Unity.dll F:\Projects\Foundation\Foundation.Core\Foundation.Common\bin\Debug\netstandard2.0\Foundation.Common.dll F:\Projects\Foundation\Foundation.Core\Foundation.Master.Unity\bin\Debug\netstandard2.0\Foundation.Master.Unity.dll F:\Projects\Foundation\Foundation.Core\Foundation.Master\bin\Debug\netstandard2.0\Foundation.Master.dll F:\Projects\LiteNetLib\LibSample\bin\Debug\LibSample.exe F:\Projects\LiteNetLib\LiteNetLibStandard\bin\Debug\netstandard2.0\LiteNetLib.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again. [12/12/2018 8:33:55 AM Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Framework35 is not supported. For projects targeting .Net Framework 3.5, please use Framework40 to run tests in CLR 4.0 "compatibility mode". at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.UpdateRunSettingsIfRequired(String runsettingsXml, List1 sources, String& updatedRunSettingsXml)
at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.DiscoverTests(DiscoveryRequestPayload discoveryPayload, ITestDiscoveryEventsRegistrar discoveryEventsRegistrar, ProtocolConfig protocolConfig)
at Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.<>c__DisplayClass20_0.b__0()
[12/12/2018 8:33:55 AM Informational] ========== Discover test finished: 0 found (0:00:03.71027) ==========
[12/12/2018 8:34:11 AM Informational] ------ Discover test started ------
[12/12/2018 8:34:11 AM Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostPath(String runtimeConfigDevPath, String depsFilePath, String sourceDirectory)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable1 sources, IDictionary2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable1 sources) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) [12/12/2018 8:34:11 AM Informational] ========== Discover test finished: 0 found (0:00:00.1339987) ========== [12/12/2018 8:34:45 AM Informational] ------ Run test started ------ [12/12/2018 8:34:45 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry. [12/12/2018 8:34:45 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry. [12/12/2018 8:34:45 AM Informational] ========== Run test finished: 0 run (0:00:00.6249972) ========== [12/12/2018 8:36:17 AM Informational] ------ Run test started ------ [12/12/2018 8:36:17 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry. [12/12/2018 8:36:17 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry. [12/12/2018 8:36:17 AM Informational] ========== Run test finished: 0 run (0:00:00.0799997) ========== [12/12/2018 8:37:43 AM Informational] ------ Discover test started ------ [12/12/2018 8:37:43 AM Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry. at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostPath(String runtimeConfigDevPath, String depsFilePath, String sourceDirectory) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable1 sources, IDictionary2 environmentVariables, TestRunnerConnectionInfo connectionInfo) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable1 sources)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
[12/12/2018 8:37:44 AM Warning] No test is available in F:\Projects\Foundation\Foundation.Core\Foundation.Common.Unity\bin\Debug\netstandard2.0\Foundation.Common.Unity.dll F:\Projects\Foundation\Foundation.Core\Foundation.Common\bin\Debug\netstandard2.0\Foundation.Common.dll F:\Projects\Foundation\Foundation.Core\Foundation.Master.Unity\bin\Debug\netstandard2.0\Foundation.Master.Unity.dll F:\Projects\Foundation\Foundation.Core\Foundation.Master\bin\Debug\netstandard2.0\Foundation.Master.dll F:\Projects\LiteNetLib\LibSample\bin\Debug\LibSample.exe F:\Projects\LiteNetLib\LiteNetLibStandard\bin\Debug\netstandard2.0\LiteNetLib.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[12/12/2018 8:37:44 AM Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Framework35 is not supported. For projects targeting .Net Framework 3.5, please use Framework40 to run tests in CLR 4.0 "compatibility mode".
at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.UpdateRunSettingsIfRequired(String runsettingsXml, List1 sources, String& updatedRunSettingsXml) at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.DiscoverTests(DiscoveryRequestPayload discoveryPayload, ITestDiscoveryEventsRegistrar discoveryEventsRegistrar, ProtocolConfig protocolConfig) at Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.<>c__DisplayClass20_0.<StartDiscovery>b__0() [12/12/2018 8:37:44 AM Informational] ========== Discover test finished: 0 found (0:00:01.0479967) ========== [12/12/2018 8:37:44 AM Informational] ------ Run test started ------ [12/12/2018 8:37:44 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry. [12/12/2018 8:37:44 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry. [12/12/2018 8:37:44 AM Informational] ========== Run test finished: 0 run (0:00:00.1630037) ========== [12/12/2018 8:38:45 AM Informational] ------ Discover test started ------ [12/12/2018 8:38:45 AM Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry. at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostPath(String runtimeConfigDevPath, String depsFilePath, String sourceDirectory) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable1 sources, IDictionary2 environmentVariables, TestRunnerConnectionInfo connectionInfo) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable1 sources)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
[12/12/2018 8:38:46 AM Warning] No test is available in F:\Projects\Foundation\Foundation.Core\Foundation.Common\bin\Debug\netstandard2.0\Foundation.Common.dll F:\Projects\LiteNetLib\LiteNetLibStandard\bin\Debug\netstandard2.0\LiteNetLib.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[12/12/2018 8:38:47 AM Informational] ========== Discover test finished: 0 found (0:00:01.2309981) ==========
[12/12/2018 8:38:53 AM Informational] ------ Run test started ------
[12/12/2018 8:38:53 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
[12/12/2018 8:38:53 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
[12/12/2018 8:38:53 AM Informational] ========== Run test finished: 0 run (0:00:00.0249969) ==========
[12/12/2018 8:42:59 AM Informational] ------ Run test started ------
[12/12/2018 8:42:59 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
[12/12/2018 8:42:59 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
[12/12/2018 8:42:59 AM Informational] ========== Run test finished: 0 run (0:00:00.1819978) ==========
[12/12/2018 8:43:49 AM Informational] ------ Run test started ------
[12/12/2018 8:43:49 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
[12/12/2018 8:43:49 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
[12/12/2018 8:43:49 AM Informational] ========== Run test finished: 0 run (0:00:00.0469877) ==========
[12/12/2018 8:47:20 AM Informational] ------ Run test started ------
[12/12/2018 8:47:21 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
[12/12/2018 8:47:21 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
[12/12/2018 8:47:21 AM Informational] ========== Run test finished: 0 run (0:00:00.0779985) ==========
[12/12/2018 8:49:43 AM Informational] ------ Discover test started ------
[12/12/2018 8:49:44 AM Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostPath(String runtimeConfigDevPath, String depsFilePath, String sourceDirectory)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable1 sources, IDictionary2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
[12/12/2018 8:49:44 AM Warning] No test is available in F:\Projects\Foundation\Foundation.Core\Foundation.Master\bin\Debug\netstandard2.0\Foundation.Master.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[12/12/2018 8:49:45 AM Informational] ========== Discover test finished: 0 found (0:00:01.1109946) ==========
[12/12/2018 8:49:45 AM Informational] ------ Run test started ------
[12/12/2018 8:49:45 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
[12/12/2018 8:49:45 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
[12/12/2018 8:49:45 AM Informational] ========== Run test finished: 0 run (0:00:00.0789987) ==========
[12/12/2018 8:51:47 AM Informational] Executing all tests in type 'Foundation.Tests.NetDataTests'
[12/12/2018 8:51:47 AM Informational] ------ Run test started ------
[12/12/2018 8:51:47 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
[12/12/2018 8:51:47 AM Error] Unable to find F:\Projects\Foundation\Foundation.Core\Foundation.Common.Tests\bin\Debug\netcoreapp2.0\testhost.dll. Please publish your test project and retry.
[12/12/2018 8:51:47 AM Informational] ========== Run test finished: 0 run (0:00:00.059002) ==========

Dependencies

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

Environment

Windows, netcoreapp2.0

Most helpful comment

Well I figured out my problem by comparing a working project with a non-working project. Apparently the VS and dotnet CLI test runners require that my test projects depend on the Microsoft.NET.Test.SDK NuGet package.

All 18 comments

Needed the NUnit test adapter project reference

@NVentimiglia could you describe how you resolved this? The test adapter package has no project file so I don't understand your solution as described. I am already referencing the NUnit3TestAdapter in my test project.

Well I figured out my problem by comparing a working project with a non-working project. Apparently the VS and dotnet CLI test runners require that my test projects depend on the Microsoft.NET.Test.SDK NuGet package.

@carlin-q-scott

I was missing the NUnit test adapter nuget project reference

Solution is to install the Microsoft.NET.Test.Sdk:

Tools>Nuget Package Manager>Manage Nuget Packages For Solution...>Search for Microsoft.NET.Test.Sdk and install for your test project.

facing same issue even after adding NUnit3TestAdapter , source and logs are attached

<ItemGroup> <PackageReference Include="nunit" Version="3.10.1" /> <PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" /> <PackageReference Include="NUnit.Runners" Version="3.9.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.10.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" /> </ItemGroup>

VSTS Logs
tasklog_6.log

Source
IntegrationTests.zip

@MuhammadBilalYar The only differences between your test project and mine are:

  • I don't have this line: <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
  • I don't have the ConsoleRunner package. I think I read somewhere that it's incompatible with the test adapter.

Had the same issue. I already had the nunit and NUnit3TestAdapter packages. The fix for me was to also add the NUnit.ConsoleRunner package. I think it's because I was trying to run within the Visual Studio Test Explorer.

I was able to run NUnit wcf test using VS Test Explorer with nuget package references like below:

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />

I had no Microsoft.NET.Test.Sdk reference before found this issue

Exactly the same issue. To solve the problem, I had to install NunitTestAdapter and Microsoft.NET.Test.Sdk. Adding just one of them did not solve the problem. Adding NuintConsoleRunner had no impact on my problem.

Exactly the same issue. To solve the problem, I had to install NunitTestAdapter and Microsoft.NET.Test.Sdk. Adding just one of them did not solve the problem.

I had a different cause, beside the ones mentioned above. The testproject was created as a console application instead of a class library. Wasn't a problem until an upgrade to .Net core 3.1

@Gert-Jan-Vernooij do you have a simple repro for this please? I am trying to repro but can't. I am getting this instead:

Error opening test data: Existing manifest is not valid.
System.InvalidOperationException: The following TestContainer was not found 'C:\Users\jajares\source\repos\ConsoleApp14\ConsoleApp14\bin\Debug\netcoreapp3.1\ConsoleApp14.dll'
   at Microsoft.VisualStudio.TestWindow.Client.TestContainer.TestContainerProvider.<GetTestContainerAsync>d__41.MoveNext()

I had the same issue even with the following installed:

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />

I was running from the bin folder but for some reason the Microsoft test DLLs were not being output to the bin folder. My solution was to publish the project and run dotnet vstest from the publish folder. Then it worked!

Perhaps NUnit3TestAdapter should add Microsoft.NET.Test.Sdk as a dependency? Seriously, spent a good while on such a waste of bytes of a problem...

The test.sdk should be forced into the project most of the times by the dotnet sdk or the new templates. Problem is when you have an older project that you run in new VS where the new version of vstest.console is built-in.

If we updated the adapter then you would not see the change until you update it, but maybe adding suggestions to install Microsoft.NET.Test.Sdk to the timeout and error messages might help? Because then it will be in the updated vstest console that we are able to control.

Fixed this issue by upgrading Microsoft.NET.Test.Sdk to 16.6.1 from 16.5.0. I am not sure what was causing this issue to suddenly appear.

For me the assembly name was wrong it was b.c changing it in projects properties to a.b.c solved it.
It was not matching the (prefix of) the namespace a.b.c.d;

Was this page helpful?
0 / 5 - 0 ratings