Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrency Issue with dotnet restore in Multi-Stage Docker Build #46561

Closed
dobri-popov-tiebreak-solutions opened this issue Feb 5, 2025 · 1 comment
Labels
Area-NuGet untriaged Request triage from a team member

Comments

@dobri-popov-tiebreak-solutions

We are experiencing a concurrency issue when running dotnet restore in a multi-stage Docker build. The issue occurs when multiple independent dotnet restore steps are executed simultaneously, leading to file access conflicts in the shared NuGet package cache directory (/root/.nuget/packages). We prefer to restore these solutions in parallel, as we need to handle tens of solutions, and performance is a critical factor.

When executing docker build -f build.Dockerfile, the following errors appear:

/usr/share/dotnet/sdk/8.0.405/NuGet.targets(174,5): error : Could not find file '/root/.nuget/packages/system.runtime.interopservices/4.1.0/shgqghmt.ntf'. [/src/Utilities/Utilitiessln]
/usr/share/dotnet/sdk/8.0.405/NuGet.targets(174,5): error : Could not find file '/root/.nuget/packages/microsoft.extensions.dependencymodel/1.1.2/2vyfq0a1.tgs'. [/src/Core/Core.sln]

To Reproduce

#syntax=docker/dockerfile:1.7-labs

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS base-build
WORKDIR /src
COPY ["nuget.config", ""]
COPY ["Directory.Build.props", ""]
COPY ["Directory.Packages.props", ""]

FROM base-build AS core-restore
COPY --parents Core/**/*.csproj Core/**/*.sln ./
RUN --mount=type=cache,target=/root/.nuget/packages \
    dotnet restore "Core/Core.sln" --packages /root/.nuget/packages

FROM base-build AS data-restore
COPY --parents Data/**/*.csproj Data/**/*.sln ./
RUN --mount=type=cache,target=/root/.nuget/packages \
    dotnet restore "Data/Data.sln" --packages /root/.nuget/packages

FROM base-build AS utilities-restore
COPY --parents Utilities/**/*.csproj Utilities/**/*.sln ./
RUN --mount=type=cache,target=/root/.nuget/packages \
    dotnet restore "Utilities/Utilities.sln" --packages /root/.nuget/packages

Logs

[core-restore 2/4] RUN --mount=type=cache,target=/root/.nuget/packages     dotnet restore "Core/Core.sln" --packages /root/.nuget/packages:
4.703   Determining projects to restore...
14.58   Restored /src/Core/Proj1/Proj1.csproj (in 1.32 sec).
18.78 /usr/share/dotnet/sdk/8.0.405/NuGet.targets(174,5): error : Could not find file '/root/.nuget/packages/microsoft.extensions.dependencymodel/1.1.2/2vyfq0a1.tgs'. [/src/Core/Core.sln]
------
------
 > [utilities-restore 2/2] RUN --mount=type=cache,target=/root/.nuget/packages     dotnet restore "Utilities/Utilities.sln" --packages /root/.nuget/packages:
4.524   Determining projects to restore...
8.490   Restored /src/Utilities/Proj1.csproj (in 1.72 sec).
13.36   Restored /src/Utilities/Proj2.csproj (in 6.56 sec).
13.65   Restored /src/Utilities/Proj3.csproj (in 6.91 sec).
13.67   Restored /src/Utilities/Proj4.csproj (in 6.92 sec).
18.62 /usr/share/dotnet/sdk/8.0.405/NuGet.targets(174,5): error : Could not find file '/root/.nuget/packages/system.runtime.interopservices/4.1.0/shgqghmt.ntf'. [/src/Utilities/Utilitiessln]
------
ERROR: failed to solve: process "/bin/sh -c dotnet restore \"Utilities/Utilities.sln\" --packages /root/.nuget/packages" did not complete successfully: exit code: 1
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NuGet untriaged Request triage from a team member labels Feb 5, 2025
@dobri-popov-tiebreak-solutions dobri-popov-tiebreak-solutions changed the title Concurrency Issue with "dotnet restore" in Multi-Stage Docker Build Concurrency Issue with dotnet restore in Multi-Stage Docker Build Feb 5, 2025
Copy link
Contributor

Thanks for creating this issue! We believe this issue is related to NuGet tooling, which is maintained by the NuGet team. Thus, we closed this one and encourage you to raise this issue in the NuGet repository instead. Don’t forget to check out NuGet’s contributing guide before submitting an issue!

If you believe this issue was closed out of error, please comment to let us know.

Happy Coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NuGet untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

1 participant