dotnet / dotnet/aspnetcore

[Trimming] MVC

Open
#41,767 3 comments 6 reactions 0 assignees View on GitHub
area-mvc enhancement linker-friendliness Priority:2
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [X] 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.