I am trying to build an ASP.NET Core project using Dockerfile
. I need to use multiple package-sources to restore the project. so I defined the package-sources into a NuGet.config
file.
Using docker, I want to copy the NuGet.config
file to my working directory so that the dotnet restore
command can use it to restore from.
Here is how my Dockerfile
look like
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
LABEL stage=build-env
WORKDIR /app
# Copy and build
COPY ./src /app
COPY ./NuGet.config /app
RUN dotnet restore /app/Project.Web --configfile ./app/NuGet.config
RUN dotnet publish /app/Project.Web -c Release -o ./build/release --framework net6.0 --no-restore
Unfortunately, the above script errors on this line COPY ./NuGet.config /app
=> ERROR [build-env 4/6] COPY ./NuGet.config /app failed to compute cache key: "/NuGet.config" not found: not found
How can I correctly copy the NuGet.config
file over to my working directory?