0

After installing Visual Studio 2017 Community, I tried creating a .NET Core unit test project. With the default output paths things work fine. But changing the intermediate output path to anything other than .\obj results in the following error.

Starting test execution, please wait... Could not find testhost.dll for source 'C:\temp\vs\cl1\p4\bin\Debug\netcoreapp1.1\p4.dll'. Make sure test project has a nuget reference of package "microsoft.testplatform.testhost".

Repro steps:

  1. Open a dotnet cli prompt.
  2. md p4
  3. cd p4
  4. dotnet new mstest
  5. edit p4.csproj to change the intermediate output path to something like obj2\.

    <PropertyGroup>
        <TargetFramework>netcoreapp1.1</TargetFramework>
        <BaseIntermediateOutputPath>obj2\</BaseIntermediateOutputPath>
    </PropertyGroup>
    
  6. dotnet restore

  7. dotnet build
  8. dotnet test

The same problem happens for both mstest and xunit projects.

Changing the output path (OutputPath) seems to work fine. It's just the intermediate output paths (BaseIntermediateOutputPath and IntermediateOutputPath) that seems to be a problem.

Adding an explicit package reference to Microsoft.TestPlatform.TestHost, as the error suggests, does not seem to help.

In the Visual Studio IDE, the same problem (presumably) manifests itself as no unit tests appearing in the Test Explorer tool window.

C. Dragon 76
  • 9,882
  • 9
  • 34
  • 41
  • How will it help you having a different Base Intermediate Output Path? – Ignas Mar 27 '17 at 09:57
  • @Ignas, My company always organizes code repositories with 3 top-level directories: src (everything under source control including .sln and .csproj), obj (intermediate output path), and bin (output path). It's mostly just a preference thing. But there are several little advantages like recursively searching just source code, blowing away a single top-level bin to ensure a full clean build, and not having to maintain extensive .gitignore (or equivalent) source control exclusion lists. – C. Dragon 76 Mar 28 '17 at 01:06
  • This sounds to me like it should be reported to [the dotnet CLI repo](https://github.com/dotnet/cli). – svick Mar 28 '17 at 13:58
  • @C.Dragon76 this error is coming because a `testproject.deps.json` or `testproject.runtimeconfig.dev.json` is not generated for the test project (`bin\Debug\netcoreapp1.1`). You can see this in `log.txt` generated from `dotnet test -d:log.txt` (enable diagnostics information). Suggest to confirm the above first. Then diagnose the build step. `dotnet build -v:diag`, see if the IntermediateOutputPath or BaseIntermediateOutputPath are set appropriately, and copying the `*.json` files to output directory. Similar issue: https://github.com/Microsoft/vstest/issues/445#issuecomment-277592096 – Arun M Apr 06 '17 at 02:18

0 Answers0