Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker removes needed runtime dependency #365

Closed
swratten opened this issue Sep 13, 2018 · 1 comment
Closed

Linker removes needed runtime dependency #365

swratten opened this issue Sep 13, 2018 · 1 comment

Comments

@swratten
Copy link

Full repro: https://github.com/swratten/docker-test just git clone and docker build

Exception at runtime:

Unhandled Exception: System.TypeLoadException: Could not load type 'Microsoft.Extensions.FileProviders.CompositeFileProvider' from assembly 'Microsoft.AspNetCore.Mvc.Razor.Extensions, Version=2.1.2.0, Culture=neutral
....
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.UseMvc(IApplicationBuilder app, Action`1 configureRoutes)
   at DockerTest.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in /app/Startup.cs:line 45

Culprit removed library:

                                                             Before linking (B)   After linking (B)    Size decrease
-----------                                                  -----------          -----------          -----------
Total size of assemblies                                     69,785,560           43,704,832           37.373%   
-----------                                                  -----------          -----------          -----------
...
Microsoft.Extensions.FileProviders.Composite.dll             17,400               0                    100.000%

This is a simple barebones webapi generated through the dotnet cli

My build commands are in the dockerfile:

https://github.com/swratten/docker-test/blob/master/Dockerfile

As suggested at #314 I ran into this previous error, so I added the workaround for that issue

In the meantime, you can work around this by setting the property CrossGenDuringPublish to false.

@vitek-karas
Copy link
Member

Even in .NET 7 wepapi projects use libraries which are not yet fully annotated for trimming, so it's possible they don't work. There has been some begining efforts in the ASP.NET repo to start annotating the libraries for trimming, but it's been slow (and difficult).

The dotnet/runtime part of the app should be trimmable, but ASP.NET libraries are a problem currently. I suggest you create a new issue in the dotnet/aspnetcore repo, updated with a project targeting .NET 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants