dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.23k stars 9.95k forks source link

WebApplicationFactory - DirectoryNotFoundException when using AssemblyName #29623

Open dominikjeske opened 3 years ago

dominikjeske commented 3 years ago

Describe the bug

In integration test when project we are testing has AssemblyName attribute we have DirectoryNotFoundException. After investigation it looks like this code https://github.com/dotnet/aspnetcore/blob/c272436a9e5dd42662d5f7eb5451c0eb0fc805c9/src/Mvac/Mvc.Testing/src/WebApplicationFactory.cs#L291 is searching for dependecies by project default names - not respecting that it could be changed by AssemblyName.

To Reproduce

  1. Create sample ASP.NET Core project
  2. Add AssemblyName with some custom name
  3. Add integrastion test project (WebApplicationFactory) and try to execute sample controller

Exceptions (if any)

DirectoryNotFoundException is raised

Further technical details

.NET SDK (reflecting any global.json): Version: 5.0.102 Commit: 71365b4d42

Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.102\

Host (useful for support): Version: 5.0.2 Commit: cb5f173b96

.NET SDKs installed: 5.0.101 [C:\Program Files\dotnet\sdk] 5.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

VS 16.8.4

javiercn commented 3 years ago

@dominikjeske thanks for contacting us.

@HaoK is this something that will not apply with the changes we made recently to Mvc.Testing?

ghost commented 3 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

dominikjeske commented 3 years ago

So maybe some update to doc's of integration test would be nice since the fix will be applied?

belgaard commented 3 years ago

It looks like it helps to explicitly include the test host nuGet package, e.g. as, <PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.4" />