Repository navigation
Closed
Copy link
Description
Bug description
I am attempting to use EF Core 8.0.21 to build a bundle for my solution, which uses Central Package Management for NuGet package versioning. When I build the bundle from the CLI, the process fails when EF Core attempts to build the bundle project.
I am assuming that the temporary project that EF Core bundling creates is explicitly setting the package version, rather than letting CPM do the heavy lifting.
Your code
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
RUN dotnet tool install --global dotnet-ef --version 8.0.21
ENV PATH="${PATH}:/root/.dotnet/tools"
WORKDIR /src
COPY ["src/Database/Database.csproj", "src/Database/"]
COPY ["Directory.*.props", "/"]
COPY ["global.json", "/"]
RUN dotnet restore "src/Database/Database.csproj"
COPY . .
WORKDIR "/src/src/Database"
RUN dotnet build "Database.csproj" --configuration Release --no-restore
FROM build AS publish
RUN dotnet ef migrations bundle --self-contained --target-runtime linux-x64 --output /app/publish --verbose --no-build --configuration Release
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["./efbundle.exe", "--connection", "$MY_CONNECTION_STRING"]Stack traces
Verbose output
Building bundle...
4.142 dotnet publish --runtime linux-x64 --output /tmp/51wygezx.pe3/publish --self-contained --configuration Release
4.875 Determining projects to restore...
6.485 /tmp/51wygezx.pe3/publish.csproj : error NU1008: Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items: Microsoft.EntityFrameworkCore.Design.
6.637 Failed to restore /tmp/51wygezx.pe3/publish.csproj (in 143 ms).
25.40 Restored /src/src/Database/Database.csproj (in 18.94 sec).
25.48 Microsoft.EntityFrameworkCore.Tools.CommandException: Build failed. Use --verbose to see errors.
25.48 at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsBundleCommand.Execute(String[] args)
25.48 at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0(String[] args)
25.48 at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
25.48 at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
25.48 Build failed. Use --verbose to see errors.
------
Dockerfile:24
--------------------
22 |
23 | FROM build AS publish
24 | >>> RUN dotnet ef migrations bundle --self-contained --target-runtime linux-x64 --output /app/publish --verbose --no-build --configuration Release
25 |
26 | FROM base AS final
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c dotnet ef migrations bundle --self-contained --target-runtime linux-x64 --output /app/publish --verbose --no-build --configuration Release" did not complete successfully: exit code: 1
EF Core version
8.0.21
Database provider
Microsoft.EntityFrameworkCore.Npgsql
Target framework
.NET 8.0
Operating system
Windows 11
IDE
JetBrains Rider 2025.2.3
Reacted by Meikel, Anthony Tong Lee and Balint Banyasz
Reacted by Copilot
Activity
nithyav2017 commentedon Nov 6, 2025
I wanted to share my findings after this on Windows with EF Core 8.0.0 and CPM via Directory.Packages.props . I hope this adds useful context.
I was able to reproduce the PackageReference conflict when explicitly defining package versions in a .csproj file while using Central Package Management via Directory.Packages.props.
However, I couldn’t confirm that EF Core CLI creates a dynamic or temporary project during the bundle process — at least not one that’s visible or inspectable during build on my local windows machine.
That said, the logs show that EF Core CLI creates temporary publish folder in %Temp% - for example :C:\Users\AppData\Local\Temp\g1kt4e4m.m5l\Publish. This folder is deleted immediately after the bundling process completes. So I couldn't inspect it whether runtime-generated .csproj and setting package version, while the version conflict is real.
IanKemp commentedon Mar 23, 2026
Please can this be fixed? It's a very subpar developer experience.
@nithyav2017 if you run
dotnet ef migrations bundle --verboseyou'll see the path to the temporary csproj that gets created. Unfortunately it's deleted immediately oncedotnet efexits, so there's no opportunity to inspect it.roji commentedon Mar 23, 2026
@IanKemp this issue is already on the plan to be fixed for 11.0.
Handle `migrations bundle` temp project generation when Central Packa…