[英]Problems with Docker multiple projects in solution .NET
This is the strucure of my folder这是我的文件夹的结构
ROOT FOLDER
|--- Login.sln
|--- Login.Api
-- Login.WebApi.csproj
|-- Domain
-- Domain.csproj
|-- BusinessLogic
|-- BusinessLogic.csproj
|---DataAccess
|-- DataAccess.csproj
|-- BusinessLogic.csproj
|---Dockerfile
And this is my current dockerfile这是我目前的 dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY . .
RUN dotnet restore "/Login/Login.WebApi.csproj"
WORKDIR "/src/."
COPY . .
RUN dotnet build "Login.WebApi.csproj" -c Release -o /app/build
FROM build as publish
RUN dotnet publish "Login.WebApi.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV ASPNETCORE_URLS http://*:PORT_NUMBER
ENTRYPOINT ["dotnet", "Login.WebApi.dll"]
Right now is not working because it can't do the restore.现在不起作用,因为它无法进行恢复。 I do not know if this is the correct way to do it
我不知道这是否是正确的方法
You don't need to do a restore;您不需要进行还原; dotnet build will do that anyway.
无论如何, dotnet build都会这样做。 Also I'd recommened you build the solution instead of individual projects.
此外,我建议您构建解决方案而不是单个项目。 And finally you don't need the double quotes.
最后你不需要双引号。 Try this:
试试这个:
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY . .
RUN dotnet build Login.sln -c Release -o /app/build
FROM build as publish
RUN dotnet publish Login.Api/Login.Api.csproj -c Release -o /app/publish
The rest of the dockerfile is ok I think.我认为 dockerfile 的其余部分没问题。
Also double check the names of the directories, they don't match your folder structure.还要仔细检查目录的名称,它们与您的文件夹结构不匹配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.