更新到 .NET 6 后,在 Docker 容器内运行 ASP.NET 应用程序时出现此错误:
An unhandled exception was thrown by the application.
System.IO.FileNotFoundException: Could not load file or assembly \u0027Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed\u0027. The system cannot find the file specified. File name: \u0027Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed\u0027
at Cadmean.RPC.ASP.FunctionController.GetFunctionCall()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine]
...
Run Code Online (Sandbox Code Playgroud)
这是我的 Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app
COPY . ./
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "DealCrackerBackend.dll"]
Run Code Online (Sandbox Code Playgroud)
库 Newtonsoft.Json 13.0.1 是来自解决方案中不同项目(类库)的引用。引用的 nuget 包 …