dockerfile中nuget源加载失败Retrying 'FindPackagesByIdAsync' for source 'xxx'
问题描述:最近jenkins打包总是提示微软源加载不到
Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.extensions.primitives/index.json'. An error occurred while sending the request.
解决方案:dockerfile中添加国内源,改用华为源就哦了,完整dockerfile文件如下:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base #RUN sed -i 's@/archive.ubuntu.com/@/mirrors.aliyun.com/@g' /etc/apt/sources.list RUN sed -i 's@dl-cdn.alpinelinux.org@mirrors.ustc.edu.cn@g' /etc/apt/sources.list RUN apt-get clean RUN apt-get update RUN apt-get -y install fonts-wqy-zenhei && apt-get clean && fc-cache -fv WORKDIR /app EXPOSE 8888 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY ./ /src RUN dotnet nuget remove source nuget.org RUN dotnet nuget add source https://repo.huaweicloud.com/repository/nuget/v3/index.json -n hw_nuget RUN dotnet restore "./xxx.Mvc/xxx.Mvc.csproj" COPY . . WORKDIR "/src/xxx.Mvc/." RUN dotnet build "xxx.Mvc.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "xxx.Mvc.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "xxx.Mvc.dll"]
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战