title: Integration Tests using XUnit.NET - Solution root could not be located using application root
body: <p>I have two projects in the solution.</p>
  <ol>
  <li>Web API using .NET Core 3.1</li>
  <li>Integration Tests using XUnit.NET and .NET Core 3.1, this project has a reference to Web API project</li>
  </ol>
  <p>A sample integration test class is here.</p>
  <pre><code>public class CustomersControllerTests : IClassFixture&lt;WebApplicationFactory&lt;WebAPIProject.Startup&gt;&gt; 
      {
              public CustomersControllerTests(WebApplicationFactory&lt;WebAPIProject.Startup&gt; factory)
              {
                  _httpClient = factory.CreateClient();
                  _customerRepository = factory.Services.GetService&lt;ICustomerRepository&gt;();            
              }
      }
  </code></pre>
  <p>I developed the integration tests using the following article.</p>
  <p><a href="https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-3.1" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-3.1</a></p>
  <p>All tests ran fine in Visual Studio.
  So the integration tests project is put into a Azure DevOps pipeline.</p>
  <p>Here are the tasks in the Agent job.</p>
  <ol>
  <li>Download Pipeline Artifacts task (to download the build artifacts from build pipeline)</li>
  <li>Visual Studio test platfrom installer task</li>
  <li>Visual Studio Test task</li>
  </ol>
  <p>All tests are failed during execution and here is the stack trace for one of the tests.</p>
  <pre><code>System.InvalidOperationException : Solution root could not be located using application root D:\a\r1\a\_ReleaseManagement.API.IntegrationTests-CI\drop\ReleaseManagement.IntegrationTests\Release\.
  [xUnit.net 00:00:06.59]       Stack Trace:
  at Microsoft.AspNetCore.TestHost.WebHostBuilderExtensions.UseSolutionRelativeContentRoot(IWebHostBuilder builder, String solutionRelativePath, String applicationBasePath, String solutionName)
  at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.SetContentRoot(IWebHostBuilder builder)
  at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.&lt;EnsureServer&gt;b__20_0(IWebHostBuilder webHostBuilder)
  at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(IHostBuilder builder, Action`1 configure)
  at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.EnsureServer()
  at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateDefaultClient(DelegatingHandler[] handlers)
  at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateDefaultClient(Uri baseAddress, DelegatingHandler[] handlers)
  at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateClient(WebApplicationFactoryClientOptions options)
  at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateClient()
  /home/vsts/work/1/s/src/UnitTests/ReleaseManagement.IntegrationTests/Api/CustomersControllerTests.cs(29,0): at ReleaseManagement.IntegrationTests.Api.CustomersControllerTests..ctor(WebApplicationFactory`1 factory)
  2020-11-27T09:54:43.4381123Z ##[error][xUnit.net 00:00:06.59]     ReleaseManagement.IntegrationTests.Api.CustomersControllerTests.CreateCustomer_Success [FAIL]
  </code></pre>
  <p>Build pipeline definition -</p>
  <pre><code>steps:
   - task: UseDotNet@2
     displayName: &quot;Use .NET Core SDK $(netCoreVersion)&quot;
     inputs:
      version: $(netCoreVersion)
  
  
   - task: DotNetCoreCLI@2
     displayName: 'Restore project dependencies'
     inputs:
      command: 'restore'
      projects: '**/ABC.IntegrationTests/ABC.IntegrationTests.csproj'
  
  
   - task: DotNetCoreCLI@2
     displayName: 'Build API Integration Tests - $(buildConfiguration)'
     inputs:
      command: 'build'
      arguments: '--configuration $(buildConfiguration) --no-restore --output $(Build.ArtifactStagingDirectory)\ABC.IntegrationTests\Release'
      projects: '**/ABC.IntegrationTests/ABC.IntegrationTests.csproj'
  
  
   - task: PublishBuildArtifacts@1
     displayName: 'Publish build artifact: drop'
     condition: succeeded()
  </code></pre>
  <p>Release pipeline definition -</p>
  <pre><code>steps:
  - task: DotNetCoreCLI@2
    displayName: 'dotnet test'
    inputs:
      command: test
      arguments: '_ABC.API.IntegrationTests-CI\drop\ABC.IntegrationTests\Release\ABC.IntegrationTests.dll'
  </code></pre>
  <p>Any help on how to resolve this issue so the tests can be executed in azure devops pipeline?</p>