© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
12 replies
ScriptKidding

✅ Error while Dockerizing an ASP.NET project which references another project.

So i am having an ASP.NET project called
ScoreManagementAPI
ScoreManagementAPI
which references another project containing EF Core Entities Models and Context called
Entities
Entities
with the directory structure as in the screenshot.
But the thing is when i try to dockerize the
ScoreManagementAPI
ScoreManagementAPI
project with the following content inside
ScoreManagementAPI/Dockerfile
ScoreManagementAPI/Dockerfile


# FROM mcr.microsoft.com/dotnet/sdk:8.0-nanoserver-1809 AS build
FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-alpine3.18-amd64 AS base
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
EXPOSE 80

# Building the core project
FROM mcr.microsoft.com/dotnet/sdk:8.0.203-alpine3.18-amd64 AS build
WORKDIR /src
RUN mkdir api Entities
COPY ["./ScoreManagementAPI/ScoreManagementAPI.csproj", "/src/api"]
COPY ["./Entities/Entities.csproj", "/src/Entities"]
RUN dotnet restore "./api/ScoreManagementAPI.csproj"
COPY ./ScoreManagementAPI ./api
COPY ./Entities /src/Entities

WORKDIR /src/api
RUN dotnet build "ScoreManagementAPI.csproj" -c Release -o /src/api/build


# Publish the application
FROM build as publish
RUN dotnet publish "ScoreManagementAPI.csproj" -c Release ./publish
# FROM mcr.microsoft.com/dotnet/sdk:8.0-nanoserver-1809 AS build
FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-alpine3.18-amd64 AS base
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
EXPOSE 80

# Building the core project
FROM mcr.microsoft.com/dotnet/sdk:8.0.203-alpine3.18-amd64 AS build
WORKDIR /src
RUN mkdir api Entities
COPY ["./ScoreManagementAPI/ScoreManagementAPI.csproj", "/src/api"]
COPY ["./Entities/Entities.csproj", "/src/Entities"]
RUN dotnet restore "./api/ScoreManagementAPI.csproj"
COPY ./ScoreManagementAPI ./api
COPY ./Entities /src/Entities

WORKDIR /src/api
RUN dotnet build "ScoreManagementAPI.csproj" -c Release -o /src/api/build


# Publish the application
FROM build as publish
RUN dotnet publish "ScoreManagementAPI.csproj" -c Release ./publish
image.png
image.png
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Asp .Net MVC --startup-project error
C#CC# / help
4y ago
✅ ASP.NET open project
C#CC# / help
2y ago
Understanding COM interface references for an ASP.NET REST API...
C#CC# / help
2y ago