Skip to content

[Trimming] MVC #41767

@JamesNK

Description

@JamesNK

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

MVC should run in a trimmed app.

Note that trimming and MVC might not be compatible. In that case, projects should be correctly annotated. e.g. MapControllers has a [RequiresUnreferencedCode] attribute on it and linker warnings are suppressed.

Describe the solution you'd like

Shipping projects under https://github.com/dotnet/aspnetcore/tree/main/src/Mvc need to add support for trimming.

See https://github.com/dotnet/aspnetcore/blob/main/docs/Trimming.md for instructions

Known issues to resolve:

  • Application parts attribute can reference assemblies that are trimmed. Ways to resolve:
    • Ignore missing assembly (not ideal. Perhaps more workable if there is a way to detect at runtime whether an app is trimmed and only do it then.)
    • Run the MSBuild task that adds part attributes after linker is run. If the linker has removed an assembly then don't include the attribute. Not sure if this is possible. May need to ask the linker/trimming team for advice here.

Tasks:

  • Resolve linker warnings
  • Integration test of calling MVC app published with trimming. Basic smoke test.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:2Work that is important, but not critical for the releasearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing onelinker-friendlinessTracking linker friendliness

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions