简体   繁体   English

如何将 class 库引用包含到 docker 文件中

[英]how to include class library reference into docker file

i'm trying to build docker file for .net core application which is having reference of class library whenever i'm trying to build docker i'm getting below error.我正在尝试为 .net 核心应用程序构建 docker 文件,每当我尝试构建 docker 时,它都会引用 class 库,但我遇到了以下错误。

Skipping project because it was not found跳过项目,因为找不到

below is the docker file which i'm using下面是我正在使用的 docker 文件

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "testapp.dll"]

You need to move the Dockerfile to the solution level, and reference the projects using [Folder]/[Project].csproj.您需要将 Dockerfile 移动到解决方案级别,并使用 [Folder]/[Project].csproj 引用项目。 Here is my Dockerfile (located in the solution level):这是我的 Dockerfile(位于解决方案级别):

FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["SumApi/SumApi.csproj", "SumApi/"]
COPY ["Shared/Shared.csproj", "Shared/"]
RUN dotnet restore "SumApi/SumApi.csproj"
COPY . .
WORKDIR "/src/SumApi"
RUN dotnet build "SumApi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "SumApi.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app`enter code here`
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SumApi.dll"]

Learned it from here: https://imranarshad.com/dockerize.net-core-web-app-with-dependent-class-library/从这里了解到: https://imranarshad.com/dockerize.net-core-web-app-with-dependent-class-library/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM