Unable to find testhost.dll. Please publish your test project and retry

In my case, the problem was that I was targeting .NET Core 2.0 and switching to .NET Core 2.1 solved the problem. However I was using Microsoft.NET.Test.SDK v16.4.0 instead of 15.9.0.


Installing Microsoft.NET.Test.Sdk package from nuget package manager solved my issue.


I had created a class library and tried to use the XUnit NuGet package in it.

What I should have done was created an XUnit project using this command: dotnet new xunit -n TestProject

I found this helpful page.