ASP.Net Core unit tests "do not match framework/platform settings"

net core unit test dependency injection
integration testing asp.net core web api
unit testing web api controllers using moq
unit testing asp.net core mvc
xunit vs nunit vs mstest
.net core 3.1 test project
asp.net unit testing
unit test web api controller request

I have an ASP.Net Core application that includes the main project, two library projects, and a unit test project. When I run the unit tests, it complains:

[7/14/2019 9:55:38 PM Informational] ------ Discover test started ------  
[7/14/2019 9:55:39 PM Warning] Test run will use DLL(s) built for framework .NETCoreApp,Version=v1.0 and platform X86. Following DLL(s) do not match framework/platform settings.  
Indigo.UnitTests.dll is built for Framework 2.2 and Platform AnyCPU.  
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.

[7/14/2019 9:55:41 PM Informational] ========== Discover test finished: 140 found (0:00:02.2274457) ==========  
[7/14/2019 9:55:41 PM Informational] ------ Run test started ------  
[7/14/2019 9:55:41 PM Warning] Test run will use DLL(s) built for framework .NETCoreApp,Version=v1.0 and platform X86. Following DLL(s) do not match framework/platform settings.  
Indigo.UnitTests.dll is built for Framework 2.2 and Platform AnyCPU.  
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.

The unit tests apparently run correctly. I've stared at my project configurations, and I've read the referenced article, but I can't figure out what it's complaining about. I've Googled the error message, but the stuff I've found doesn't seem to apply to my situation.

Here are my csproj files (FWIW):

The main project:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <UserSecretsId>xxx</UserSecretsId>
    <ApplicationInsightsResourceId>xxx</ApplicationInsightsResourceId>
    <ApplicationInsightsAnnotationResourceId>xxx</ApplicationInsightsAnnotationResourceId>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
    <TypeScriptToolsVersion>3.4</TypeScriptToolsVersion>
  </PropertyGroup>

    <ItemGroup>
        <DotnetPublishFiles Include="App_Data/**/*">
            <DestinationRelativePath>App_Data/%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
        </DotnetPublishFiles>
    </ItemGroup>

    <ItemGroup>
    <Content Remove="wwwroot\bundles\ajax.js" />
    <Content Remove="wwwroot\bundles\captive-page.js" />
    <Content Remove="wwwroot\bundles\captive-page.min.js" />
    <Content Remove="wwwroot\bundles\datepicker.js" />
    <Content Remove="wwwroot\bundles\datepicker.min.js" />
    <Content Remove="wwwroot\bundles\ihi-validation-extensions.min.js" />
    <Content Remove="wwwroot\bundles\jquery-validation.js" />
    <Content Remove="wwwroot\bundles\main.js" />
    <Content Remove="wwwroot\bundles\signalr.js" />
    <Content Remove="wwwroot\bundles\signalr.min.js" />
  </ItemGroup>

  <ItemGroup>
    <_ContentIncludedByDefault Remove="wwwroot\bundles\ajax.js" />
    <_ContentIncludedByDefault Remove="wwwroot\bundles\captive-page.js" />
    <_ContentIncludedByDefault Remove="wwwroot\bundles\captive-page.min.js" />
    <_ContentIncludedByDefault Remove="wwwroot\bundles\datepicker.js" />
    <_ContentIncludedByDefault Remove="wwwroot\bundles\datepicker.min.js" />
    <_ContentIncludedByDefault Remove="wwwroot\bundles\ihi-validation-extensions.min.js" />
    <_ContentIncludedByDefault Remove="wwwroot\bundles\jquery-validation.js" />
    <_ContentIncludedByDefault Remove="wwwroot\bundles\main.js" />
    <_ContentIncludedByDefault Remove="wwwroot\bundles\main.min.css" />
    <_ContentIncludedByDefault Remove="wwwroot\bundles\signalr.js" />
    <_ContentIncludedByDefault Remove="wwwroot\bundles\signalr.min.js" />
  </ItemGroup>


  <ItemGroup>
    <PackageReference Include="Flee" Version="1.2.2" />
    <PackageReference Include="Humanizer" Version="2.6.2" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.7.1" />
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.2.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.5" />
    <PackageReference Include="Microsoft.TypeScript.MSBuild" Version="3.5.2">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" PrivateAssets="All" />
    <PackageReference Include="Neleus.DependencyInjection.Extensions" Version="1.0.0" />
    <PackageReference Include="Sakura.AspNetCore.Mvc.PagedList" Version="2.0.12" />
    <PackageReference Include="Sakura.AspNetCore.PagedList" Version="2.0.2" />
    <PackageReference Include="Sakura.AspNetCore.PagedList.Async" Version="1.0.0" />
    <PackageReference Include="Sendgrid" Version="9.11.0" />
    <PackageReference Include="Twilio" Version="5.31.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\ihi.Lib.Web\ihi.Lib.Web.csproj" />
    <ProjectReference Include="..\..\ihi.Lib\ihi.Lib.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Areas\Identity\Services\" />
  </ItemGroup>

  <ItemGroup>
    <None Include="wwwroot\bundles\ajax.js" />
    <None Include="wwwroot\bundles\captive-page.js" />
    <None Include="wwwroot\bundles\captive-page.min.js" />
    <None Include="wwwroot\bundles\datepicker.js" />
    <None Include="wwwroot\bundles\datepicker.min.js" />
    <None Include="wwwroot\bundles\ihi-validation-extensions.min.js" />
    <None Include="wwwroot\bundles\jquery-validation.js" />
    <None Include="wwwroot\bundles\main.js" />
    <None Include="wwwroot\bundles\signalr.js" />
    <None Include="wwwroot\bundles\signalr.min.js" />
  </ItemGroup>

  <ItemGroup>
    <WCFMetadata Include="Connected Services" />
  </ItemGroup>

</Project>

The unit test project:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
    <PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\ihi.Lib.Web\ihi.Lib.Web.csproj" />
    <ProjectReference Include="..\..\ihi.Lib\ihi.Lib.csproj" />
    <ProjectReference Include="..\Indigo\Indigo.csproj" />
  </ItemGroup>

</Project>

The first library project:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="libphonenumber-csharp" Version="8.10.14" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
    <PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
    <PackageReference Include="protobuf-net" Version="2.4.0" />
  </ItemGroup>

</Project>

The second library project:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Braintree" Version="4.12.0" />
    <PackageReference Include="Markdig" Version="0.17.0" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.7.1" />
    <PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="protobuf-net" Version="2.4.0" />
    <PackageReference Include="RestSharp" Version="106.6.10" />
    <PackageReference Include="Sendgrid" Version="9.11.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\ihi.Lib\ihi.Lib.csproj" />
  </ItemGroup>

</Project>

This problem seems to be fixed in Visual Studio 16.2.2.

Testing ASP.NET Core services and web apps, Implementing unit tests for ASP.NET Core Web APIs. Unit testing involves testing a part of an application in isolation from its infrastructure and  For more information on integration tests, see Integration tests in ASP.NET Core. If you're writing custom filters and routes, unit test them in isolation, not as part of tests on a particular controller action. To demonstrate controller unit tests, review the following controller in the sample app. View or download sample code (how to download)


Unit testing in .NET Core and .NET Standard, After you set up your test project, you will be able to run your unit tests using the command line or Visual Studio. If you're testing an ASP.NET  ASP.NET Core supports unit tests of Razor Pages apps. Tests of the data access layer (DAL) and page models help ensure: Parts of a Razor Pages app work independently and together as a unit during app construction. Classes and methods have limited scopes of responsibility. Additional documentation exists on how the app should behave.


I recently ran into this one on VS 2019 16.5.2 - turns out the project was updated to Microsoft.NET.Test.Sdk 16.5 - downgrading to 16.2 fixed my issue. I got v16.2 by successivley downgrading one version at a time. 16.4 and so on.

Seems Microsoft.NET.Test.Sdk 16.5 requires NET Core 3.0+

Unit Testing in ASP .NET Core, In this article we are going to cover Unit Testing or rather why we need unit tests and how to implement them in our ASP.NET Core applications. In Visual Studio 2019, search for “.net core test project” when creating a new project to identify test projects for MSTest, XUnit and NUnit. Select the XUnit project to follow along with the NetLearner samples. Test Project Templates in Visual Studio 2019. The placeholder unit test class includes a blank test.


Unit Testing in ASP.NET Core MVC, Find out what Unit testing is and how to write unit tests in ASP.NET Core Web API Project. There, we have explained how to implement unit testing in an ASP.NET Core Web API project. However, in this article, we’ll focus on how to write unit tests for an ASP.NET Core MVC project. A unit test is meant to test a single part of our application’s logic. Our code may have dependencies on lower layers and external components.


Unit Testing in ASP.NET Core Web API, The testing triangle is a good guide for your ASP.NET core testing strategies. Unit Tests. Unit tests are the smallest sort of tests that you'll write. Setting up Unit Testing The quickest way to set up unit testing for an ASP.NET Core web app project is to create a new test project using a template. This creates a cross-platform.NET Core project that includes one blank test.


ASP.NET Core Testing Tools and Strategies, UnitTests project. Now we proceed to add code related for unit tests, these tests will work with In memory database. What is TDD? Testing is a common  ASP.NET Core supports integration tests using a unit test framework with a test web host and an in-memory test server. This topic assumes a basic understanding of unit tests. If unfamiliar with test concepts, see the Unit Testing in.NET Core and.NET Standard topic and its linked content. View or download sample code (how to download)