程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了错误 [build 6/6] RUN dotnet publish "" -c Release -o /app/publish大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决错误 [build 6/6] RUN dotnet publish "" -c Release -o /app/publish?

开发过程中遇到错误 [build 6/6] RUN dotnet publish "" -c Release -o /app/publish的问题如何解决?下面主要结合日常开发的经验,给出你关于错误 [build 6/6] RUN dotnet publish "" -c Release -o /app/publish的解决方法建议,希望对你解决错误 [build 6/6] RUN dotnet publish "" -c Release -o /app/publish有所启发或帮助;

我正在为 Web API .Net 5 构建图像

我的文件夹目录如下

D:\Working\phong_Nguyen_Super_Hero\Weather Forecast Application\WeatherForecast-main\TLY.WeatherForecast
                               |- TLY.WeatherForecast.sln
                               |- Dockerfile
                               |- .dockerignore
                               |- TLY.WeatherForecast

我的 Dockerfile 内容是这样的

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
workdir /app
EXPOSE 80

ENV ASPNETCORE_URLS=http://+:80

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
workdir /src
copY ["TLY.WeatherForecast/TLY.WeatherForecast.csproj","TLY.WeatherForecast/"]
RUN dotnet restore "TLY.WeatherForecast/TLY.WeatherForecast.csproj"
copY . .
RUN dotnet publish "TLY.WeatherForecast.csproj" -c Release -o /app/publish

FROM base AS final
workdir /app
copY --from=build /app/publish .
ENTRYPOINT ["dotnet","TLY.WeatherForecast.dll"]

当我运行这个命令时

docker build -t phongnguyen94/weatherforecast_API:latest .

我在下面遇到错误

> [+] Building 110.7s (14/15)  => [internal] load build deFinition from
> Dockerfile                                                            
=> transferring dockerfile: 569B                                                                                                                               
=> [internal] load .dockerignore                                                                                                                                  
=> transferring context: 388B                                                                                                                                  
=> [internal] load Metadata for mcr.microsoft.com/dotnet/sdk:5.0                                      
=> [internal] load Metadata for mcr.microsoft.com/dotnet/aspnet:5.0                                   
=> [internal] load build context                                                                                                                                 
=> transferring context: 4.46MB                                                                                                                                
=> [base 1/2] FROM mcr.microsoft.com/dotnet/aspnet:5.0@sha256:c0cc95b0d87a31401763f8c7b2a25aa106e7b45bfcaa2f302dc9d0ff5ab93fa2
=> => resolve mcr.microsoft.com/dotnet/aspnet:5.0@sha256:c0cc95b0d87a31401763f8c7b2a25aa106e7b45bfcaa2f302dc9d0ff5ab93fa2
=> extracTing sha256:1396b16d0d87d441988017c78df3fe711ae12f60cce661c2a9a004bdce6f4ee3
=> [build 1/6] FROM mcr.microsoft.com/dotnet/sdk:5.0@sha256:85ea9832ae26c70618418cf7c699186776ad066d88770fd6fd1edea9b260379a
=> resolve mcr.microsoft.com/dotnet/sdk:5.0@sha256:85ea9832ae26c70618418cf7c699186776ad066d88770fd6fd1edea9b260379a
=> extracTing sha256:9887694812e570c8e6fab2fbffd327127283e4360cce25677d9ee7a7c309162d
=> [base 2/2] workdir /app                                                                                                                                        
=> [final 1/2] workdir /app                                                                                                                                       
=> [build 2/6] workdir /src                                                                                                                                       
=> [build 3/6] copY [TLY.WeatherForecast/TLY.WeatherForecast.csproj,TLY.WeatherForecast/]
=> [build 4/6] RUN dotnet restore "TLY.WeatherForecast/TLY.WeatherForecast.csproj"                      
=> [build 5/6] copY . .                                                                                                                                           
=> ERROR [build 6/6] RUN dotnet publish "TLY.WeatherForecast.csproj" -c Release -o /app/publish

------
 > [build 6/6] RUN dotnet publish "TLY.WeatherForecast.csproj" -c Release -o /app/publish:
#14 0.578 Microsoft (R) Build ENGIne version 16.9.0+57a23d249 for .NET
#14 0.578 copyright (C) Microsoft Corporation. All rights reserved.
#14 0.578
#14 0.579 MSBUILD : error MSB1009: Project file does not exist.
#14 0.579 Switch: TLY.WeatherForecast.csproj

解决方法

我已经更改了这一行的 Dockerfile 内容,然后它工作正常

来自

RUN dotnet publish "TLY.WeatherForecast.csproj" -c Release -o /app/publish

RUN dotnet publish "TLY.WeatherForecast/TLY.WeatherForecast.csproj" -c Release -o /app/publish

因为我已将 Dockerfile 文件放在项目之外。所以我需要重定向到 TLY.WeatherForecast 文件夹。

错误 [build 6/6] RUN dotnet publish "" -c Release -o /app/publish

大佬总结

以上是大佬教程为你收集整理的错误 [build 6/6] RUN dotnet publish "" -c Release -o /app/publish全部内容,希望文章能够帮你解决错误 [build 6/6] RUN dotnet publish "" -c Release -o /app/publish所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。