我正在使用 Visual Studio 2019(启用 Docker 支持)编写一个 .Net Core 3.1 Worker Service 应用程序。
如果我使用 Docker 启动应用程序一切正常,但是当我Serilog.AspNetCore 3.4.0
向项目添加依赖项时,我无法再使用 docker 进行调试。
案例:
- 在没有 Serilog 的情况下在本地启动应用程序 --> OK
- 在没有 Serilog 的 Docker 上启动应用程序 --> OK
- 使用 Serilog 在本地启动应用程序 --> OK
- 使用 Serilog 在 Docker 上启动应用程序 --> 错误
Visual Studio 返回的错误是:
这是控制台返回的错误:
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
It was not possible to find any compatible framework version
The framework 'Microsoft.AspNetCore.App', version '3.1.0' was not found.
- No frameworks were found.
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=x64&rid=debian.10-x64
The program 'dotnet' has exited with code 150 (0x96).
编辑:
这是 VS 2019 自动生成的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/core/runtime:3.1-buster-slim AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["MensaNotificationService/MensaNotificationService.csproj", "MensaNotificationService/"]
RUN dotnet restore "MensaNotificationService/MensaNotificationService.csproj"
COPY . .
WORKDIR "/src/MensaNotificationService"
RUN dotnet build "MensaNotificationService.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MensaNotificationService.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MensaNotificationService.dll"]
问题是什么,我该如何解决?