Moving from dotnet/core-setup#4923 on behalf of @JulidaRocks
Upgraded from dotnet core 2.1 to 2.2. When running the integration tests, an exception is thrown when initializing TestServer with
var testServer = new Microsoft.AspNetCore.TestHost.TestServer(webHostBuilder);
Should create the test server object
throws exception
Stack trace:
at
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at Microsoft.AspNetCore.TestHost.TestServer..ctor(IWebHostBuilder builder, IFeatureCollection featureCollection)
at
at
Packages in .Api-project
```xml
Packages in .Api.IntegrationTests-project:
```xml
<ItemGroup>
<PackageReference Include="Equ" Version="2.0.2" />
<PackageReference Include="FluentAssertions" Version="5.5.3" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
<PackageReference Include="SimpleInjector" Version="4.4.3" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
Any suggestions?
Also getting something similar for our integration tests - Could not load file or assembly 'Microsoft.AspNetCore.Cors, Version=2.2.0.0
I was having the issue with the Microsoft.AspNetCore
file or assembly, and solved it by adding a package reference to the test project, like so:
<PackageReference Include="Microsoft.AspNetCore.App" />
@mrlund thanks, this fixed the issue!
Most helpful comment
I was having the issue with the
Microsoft.AspNetCore
file or assembly, and solved it by adding a package reference to the test project, like so:<PackageReference Include="Microsoft.AspNetCore.App" />