Skip to content

integration tests using WebApplicationFactory fail when running in a docker container from the output of dotnet publish with "Solution root could not be located using application root" error #16978

@haridasnykiel

Description

@haridasnykiel

I have some integration tests that we want to run in a docker container using vstest from a published project.
The WebApplicationFactory is used to build a test server to host the service which is started for every test.
All the files from the output of the publish and copy it to a directory called app in the container.

This issue is very similar and there is a solution for the issue that I am unsure how to implement. Could I get a more detailed implementation details? Details below:

#10944

solution:
WAF can be extended to support this by adding your ownhttps://github.com/aspnet/AspNetCore/blob/master/src/Mvc/Mvc.Testing/src/WebApplicationFactoryContentRootAttribute.cs to the test assembly. Pointing at the content root of the published app.

To Reproduce

  1. create integration tests for a dotnet api project
  2. publish the integration tests
  3. copy the published files to the docker container
  4. build the image
  5. run the container

Exception:

Error Message:
System.InvalidOperationException : Solution root could not be located using application root

Further technical details

  • netcoreapp2.2

  • .NET Core SDK (reflecting any global.json):
    Version: 2.2.103
    Commit: 8edbc2570a

Runtime Environment:
OS Name: debian
OS Version: 9
OS Platform: Linux
RID: debian.9-x64
Base Path: /usr/share/dotnet/sdk/2.2.103/

Host (useful for support):
Version: 2.2.1
Commit: 878dd11e62

.NET Core SDKs installed:
2.2.103 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

  • VS 2019

Metadata

Metadata

Assignees

Labels

✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesquestion

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions