You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ASP.NET Core容器化应用Debug模式正常,切换Test/Release构建配置时出现SSL证书及程序集加载错误求助

ASP.NET Core容器化应用Debug模式正常,切换Test/Release构建配置时出现SSL证书及程序集加载错误求助

各位大佬好,我遇到了一个挺棘手的问题,想请大家帮忙看看:

我有一个用DevExtreme(DevExpress的UI包)开发的ASP.NET Core容器化应用,本地Debug模式下运行容器完全正常,但切换到Test或者Release构建配置时,就会接连抛出两个错误:

第一个错误:dotnet restore时的SSL证书链问题

在Dockerfile执行dotnet restore步骤时,所有DevExpress相关的NuGet包都拉取失败,错误信息都是SSL连接建立失败,证书链存在PartialChain错误,比如:

#16 [build 6/9] RUN dotnet restore "./MyProject/MyProject.csproj"
#16 1.066 Determining projects to restore...
#16 1.779 Retrying 'FindPackagesByIdAsyncCore' for source 'https://nuget.devexpress.com/xxxxxxxxxxxxxxxxxxxxxxxxxx/api/FindPackagesById()?id='DevExpress.Drawing.Skia'&semVerLevel=2.0.0'.
#16 1.779 The SSL connection could not be established, see inner exception.
#16 1.779 The remote certificate is invalid because of errors in the certificate chain: PartialChain
#16 1.798 Retrying 'FindPackagesByIdAsyncCore' for source 'https://nuget.devexpress.com/xxxxxxxxxxxxxxxxxxxxxxxxxx/api/FindPackagesById()?id='DevExtreme.AspNet.Core'&semVerLevel=2.0.0'.
#16 1.798 The SSL connection could not be established, see inner exception.
#16 1.798 The remote certificate is invalid because of errors in the certificate chain: PartialChain

最终因为这个问题,dotnet restore执行失败,退出码为1。

第二个错误:程序集加载失败

当restore失败后,后续流程会抛出程序集找不到的错误:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

我想请教的是:针对容器化的ASP.NET Core应用,在切换非Debug构建配置时,是不是有什么我没注意到的配置或者步骤需要调整?

附上我的Dockerfile内容:

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
#Install dependencies
RUN apt-get update
RUN apt-get install -y libc6 libicu-dev libfontconfig1
WORKDIR /app
EXPOSE 80
EXPOSE 443
ENV ASPNETCORE_URLS=https://+:443;http://+:80

# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["MyApp/NuGet.config", "MyApp/"]
COPY ["NuGet.config", "."]
COPY ["MyApp/MyApp.csproj", "MyApp/"]
RUN dotnet restore "./MyApp/MyApp.csproj"
COPY . .
WORKDIR "/src/MyApp"
RUN dotnet build "./MyApp.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
RUN dotnet publish "MyApp.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyApp.dll"]

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.07 08:02:58