dotnet / dotnet/sdk

SDK: Allow limiting runtimes folder output to a list of runtime identifiers

Open
#42,153 13 comments 7 reactions 2 assignees Claimed by @baronfel View on GitHub
Area-NetSDK Partner request
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Is your feature request related to a problem? Please describe.
We have a space issue where a lot of space is wasted repeatedly on runtime we do not need. An example case is having developers on Windows, testing on Windows, and deploying to Linux. In total, we need to build and test on `linux-64;win-x64`, and only deploy to `linux-x64`. But as far as we can tell, nothing exists between handling a _single_ `RuntimeIdentifier` (e.g. publishing) and all platforms (e.g. any normal build).

For example, let's take [Mono.Posix](https://www.nuget.org/packages/Mono.Posix/7.1.0-final.1.21458.1) which relies on [Mono.Unix](https://nuget.info/packages/Mono.Unix/7.1.0-final.1.21458.1). The runtimes folder looks like this:
> ![Image](https://github.com/user-attachments/assets/0814baf1-b8f7-4e19-a11e-814612aae03b)

We need only `linux-x64` (~117KB), not all 18 runtimes (6,503 KB).

This is one example, but the problem repeats for many packages. In many of our Windows/Linux scenarios roughly half the output is the `runtimes` folder of which we need ~30% of it. With many of these projects it adds up to about 200MB of our total 12.7GB output (which includes a lot of payloads outside .NET).

### Describe the solution you'd like
I'd like to be able to filter this to the platforms we support, Windows and Linux (usually x64 but very rarely x86). For example:
```xml

liunux-x64;win-x64

```

### Additional context
I included the screenshot above to illustrate the drastic difference in current vs. output that'll ever be used. Many teams are only running on x64 these days. I'd wager _most_ teams are not outputting for ios, androis, tvos, etc. For so many services these extra outputs add up quite a bit when we know they'll never be used. The ability to filter these out at build time (rather than some post-build cleanup step) would be a nice addition and save resources.

Note: we can't _only_ include the filters directly since RIDs have derivatives. For example, `win-x64` would need to include `win` and `any`, similarly for `linux-x64` -> `linux` -> `unix` -> `any`. This logic for RIDs makes cleanup itself more complicated than users first expect when trying to do some post-build cleanup workaround. It'd be better/safer if this was part of the build which is aware of the RID graph.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.