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

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

Closed
NVentimiglia opened this issue Dec 12, 2018 · 18 comments

Comments

@NVentimiglia
Copy link

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

@NVentimiglia
Copy link
Author

Needed the NUnit test adapter project reference

@carlin-q-scott
Copy link

@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.

@carlin-q-scott
Copy link

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.

@NVentimiglia
Copy link
Author

@carlin-q-scott

I was missing the NUnit test adapter nuget project reference

@antgustech
Copy link

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.

@MuhammadBilalYar
Copy link

MuhammadBilalYar commented Jan 16, 2019

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

@carlin-q-scott
Copy link

@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.

@scottblasingame
Copy link

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.

@oleksabor
Copy link

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

@AndiKleini
Copy link

AndiKleini commented Nov 13, 2019

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.

@chandan11a
Copy link

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.

@Gert-Jan-Vernooij
Copy link

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

@nohwnd
Copy link
Member

nohwnd commented Mar 4, 2020

@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()

@m17kea
Copy link

m17kea commented Mar 6, 2020

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!

@RedSpiderMkV
Copy link

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...

@nohwnd
Copy link
Member

nohwnd commented Mar 24, 2020

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.

@PSanetra
Copy link

PSanetra commented May 5, 2020

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.

@qsdfplkj
Copy link

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;

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

No branches or pull requests