Papercut - add support for `--arch` in dotnet ef migrations bundle
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
**TL;DR;**
Add support for the `--arch` argument to `dotnet ef migrations bundle` for parity with `dotnet restore` and `dotnet publish`
I am trying to dockerize my ASP.Net Core application. I plan to build Docker images for different operating systems (mostly linux-64 and linux-arm) from a single Dockerfile. The application uses EF to work with a database. To be able to update my database I create a migrations bundle when building the image.
To prepare the application I can just pass the `--arch` to `dotnet restore` or `dotnet publish` commands like this:
```
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG TARGETARCH
WORKDIR /source
COPY *.csproj .
RUN dotnet restore -a $TARGETARCH
COPY . .
RUN dotnet publish -a $TARGETARCH -o /demo --self-contained
```
This doesn't work for `dotnet ef migrations bundle` as it doesn't support the `--arch` argument. I found that it is possible to achieve the same result by using the `--target-runtime` parameter that takes a RID. The RID can be created just by stitching OS and ARCH similarly to how [dotnet tooling does it](https://github.com/dotnet/sdk/blob/1223a7c2ff42912e887c180ab0dd21db7a2d507f/src/Cli/dotnet/CommonOptions.cs#L227):
```
ARG TARGETOS
dotnet ef migrations bundle --target-runtime $TARGETOS-$TARGETARCH -c ApplicationDbContext -o /demo/app-migrations --self-contained
```
This works but is cumbersome as it introduces one more concept (RID) to the Dockerfile. It would be nice if `dotnet ef migrations bundle` also supported the `--arch` parameter.
One interesting nuance is that the `dotnet publish` and `restore` commands support `-a` as a shortcut for `--arch` but in `dotnet ef migrations bundle` `-a` is already reserved for `--assembly`
Contributor guide
Assessment
This issue has not been assessed yet.