You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a web application that needs to run a tool as a build step. The tool is developed as a console application that also needs to load a configuration file so there is a reference to Microsoft.Extensions.Hosting. This console application is referenced by the web application. When building the web application I get the following exception:
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Hosting.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.Extensions.Hosting.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
This was working on .NET 5 but does no longer work after migrating to .NET 6. I think this is similar to #22053 but haven't been able to make it work using the solution provided in the discussion.
I'm attaching a sample project that reproduces the issue: ExeReference.zip
The text was updated successfully, but these errors were encountered:
What's going on here is that the Microsoft.Extensions.Hosting APIs are available both as a NuGet package and as part of the ASP.NET Core shared framework. The Console app references them as a NuGet package reference. The Web app gets them via the implicit ASP.NET Core FrameworkReference, and the conflict resolution process in the build removes the DLLs that came in transitively from the PackageReference, because the ones supplied by the shared framework are preferred.
However, the console app's runtimeconfig doesn't specify that it depends on the ASP.NET Core shared framework, so when it tries to run it doesn't have access to those DLLs from the shared framework, and it also can't find them in the current folder because they were trimmed out by conflict resolution when building the web app.
For situations like this, I would recommend having the Console app use the ASP.NET Core shared framework so that it matches the web app it's being copied into. You can replace the PackageReference with this:
Uh oh!
There was an error while loading. Please reload this page.
Hi.
I have a web application that needs to run a tool as a build step. The tool is developed as a console application that also needs to load a configuration file so there is a reference to
Microsoft.Extensions.Hosting
. This console application is referenced by the web application. When building the web application I get the following exception:This was working on .NET 5 but does no longer work after migrating to .NET 6. I think this is similar to #22053 but haven't been able to make it work using the solution provided in the discussion.
I'm attaching a sample project that reproduces the issue: ExeReference.zip
The text was updated successfully, but these errors were encountered: