Integration testing ASP.NET Core with .NET Framework - can't find deps.json

I just ran into this same issue and found the root cause to be quite obscure. From the documentation, the .deps files should be copied to the integration test project's bin directory. This wasn't happening for me because was not explicitly referencing the Microsoft.AspNetCore.Mvc.Testing package from my integration test project. I had created a shared library with some utility functions that referenced that nuget package, so my integration test project indirectly referenced it.

There's some custom build tasks in the Microsoft.AspNetCore.Mvc.Testing package that copy the referenced service deps.json files for you, so you must reference it directly from the integration test project in order to get those build tasks to run.


Follow steps below to create Integration Test for Asp.Net Core with targeting net 47.

  1. Create New Project-> xUnit Test Project(.Net Core)
  2. Right click new project->Edit .csproj->Change TargetFramework to net47
  3. Add Project Reference to TestRepro
  4. Install-Package Microsoft.AspNetCore.Mvc.Testing
  5. Add Test file like below

    public class BasicTests
    : IClassFixture<WebApplicationFactory<Startup>>
    {
        private readonly WebApplicationFactory<Startup> _factory;
    
        public BasicTests(WebApplicationFactory<Startup> factory)
        {
            _factory = factory;
        }
    
        [Fact]
        public async Task TestMethod1()
        {
            var client = _factory.CreateClient();
            var response = await client.GetAsync("/api/values");
        }
    
    }
    
  6. Run Test Project


For me, I already had a reference to Microsoft.AspNetCore.Mvc.Test in my test project, but removing the following fixed the issue:

<GenerateAssemblyInfo>false</GenerateAssemblyInfo>