Skip to content

Instantly share code, notes, and snippets.

@heberop
Created August 26, 2021 11:51
Show Gist options
  • Save heberop/afdbdfb014b799e01e141c617422252a to your computer and use it in GitHub Desktop.
Save heberop/afdbdfb014b799e01e141c617422252a to your computer and use it in GitHub Desktop.
Dockerfile sample copying first .sln and .csproj only and restore
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS builder
WORKDIR /build
COPY src/*.sln ./nuget.config ./
COPY src/*/*.csproj ./
RUN for from in ./*.csproj; do to=$(echo "$from" | sed 's/\/\([^/]*\)\.csproj$/\/\1&/') \
&& mkdir -p "$(dirname "$to")" && mv "$from" "$to"; done
RUN dotnet restore --configfile ./nuget.config
COPY src/. ./
RUN dotnet build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment