简体   繁体   English

Docker 容器找不到 .NET 框架

[英]Docker container unable to find .NET framework

I have recently upgraded a .NET project from the 2.0 framework to 2.1.我最近将一个 .NET 项目从 2.0 框架升级到 2.1。 As described in the guidelines, I have replaced the Microsoft.AspNetCore.All with Microsoft.AspNetCore.App.如指南中所述,我已将 Microsoft.AspNetCore.All 替换为 Microsoft.AspNetCore.App。 Since the 2.1.0 version contains a lot of vulnerabilities, I am explicitly specifying the version of the package as 2.1.23 (latest for 2.1 according to NuGet).由于 2.1.0 版本包含很多漏洞,我明确指定 package 的版本为 2.1.23(根据 NuGet 最新为 2.1)。

The building of the project works fine as well as building the docker image.该项目的构建工作正常以及构建 docker 映像。 However, when I try to run the docker container, I get the following error:但是,当我尝试运行 docker 容器时,出现以下错误:

cord-notifier                 | It was not possible to find any compatible framework version
cord-notifier                 | The specified framework 'Microsoft.AspNetCore.App', version '2.1.23' was not found.
cord-notifier                 |   - Check application dependencies and target a framework version installed at:
cord-notifier                 |       /usr/share/dotnet/
cord-notifier                 |   - Installing .NET Core prerequisites might help resolve this problem:
cord-notifier                 |       https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
cord-notifier                 |   - The .NET Core framework and SDK can be installed from:
cord-notifier                 |       https://aka.ms/dotnet-download
cord-notifier                 |   - The following versions are installed:
cord-notifier                 |       2.1.20 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
cord-notifier exited with code 150

The docker base image that I am using is FROM mcr.microsoft.com/dotnet/core/sdk:2.2 I have tried switching to 2.1 as well but that does not do the trick either.我使用的 docker 基本映像是FROM mcr.microsoft.com/dotnet/core/sdk:2.2我也尝试过切换到 2.1,但这也不起作用。 I don't use the aspcore one because that does not have the SDK tools installed (such as dotnet).我不使用 aspcore 之一,因为它没有安装 SDK 工具(例如 dotnet)。

I tried listing the SDKs and runtime images on my machine and I can see that everything is installed there.我尝试在我的机器上列出 SDK 和运行时映像,我可以看到所有东西都安装在那里。

Microsoft.AspNetCore.All 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.23 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.23 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.22 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.23 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

And the SDKs和 SDK

2.1.300 [/usr/local/share/dotnet/sdk]
2.1.403 [/usr/local/share/dotnet/sdk]
2.1.701 [/usr/local/share/dotnet/sdk]
2.1.811 [/usr/local/share/dotnet/sdk]
2.2.207 [/usr/local/share/dotnet/sdk]
3.0.100 [/usr/local/share/dotnet/sdk]
3.1.101 [/usr/local/share/dotnet/sdk]
3.1.102 [/usr/local/share/dotnet/sdk]
3.1.402 [/usr/local/share/dotnet/sdk]
5.0.101 [/usr/local/share/dotnet/sdk]

I am running out of ideas on how to solve this.我已经没有关于如何解决这个问题的想法了。 Thank you in advance!先感谢您!

Edit: Added the dockerfile编辑:添加了 dockerfile

I use this docker file for the image itself.我将这个 docker 文件用于图像本身。 But for local dev, we have a different setup.但是对于本地开发人员,我们有不同的设置。

FROM dotnet-core-sdk-2.2-debug:latest AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY CordNotifier/cordfinance.webapi.utils.2.2.101.nupkg /Packages
COPY CordNotifier/cordfinance.webapi.utils.2.2.101.nupkg.sha512 /Packages
COPY CordNotifier/cordfinance.webapi.utils.nuspec /Packages
COPY CordNotifier/CordNotifier.csproj CordNotifier/
COPY CordNotifierDataModel/CordNotifierDataModel.csproj CordNotifierDataModel/
COPY Shared/Shared.csproj Shared/

 RUN dotnet restore CordNotifier/CordNotifier.csproj
#RUN dotnet list CordNotifier/CordNotifier.csproj package

# Copy everything else and build
COPY ./ ./
RUN dotnet publish CordNotifier/CordNotifier.csproj -c Debug -o out --no-restore

# Build runtime image
FROM dotnet-core-aspnet-2.1-debug:latest
WORKDIR /app

COPY --from=build-env /app/CordNotifier/out .

ENTRYPOINT ["dotnet", "CordNotifier.dll"]

where dotnet-core-sdk-2.2-debug:latest comes from dotnet-core-sdk-2.2-debug:latest来自哪里

FROM mcr.microsoft.com/dotnet/core/sdk:2.1

ENV ASPNETCORE_ENVIRONMENT=Development

# Global NuGet Configuration
COPY Packages/NuGet.config /root/.nuget/NuGet/NuGet.Config


# Populate Nuget Package Cache
COPY Packages Packages
RUN dotnet restore Packages/Packages.csproj; exit 0

I have recently upgraded a .NET project from the 2.0 framework to 2.1.我最近将一个 .NET 项目从 2.0 框架升级到 2.1。 As described in the guidelines, I have replaced the Microsoft.AspNetCore.All with Microsoft.AspNetCore.App.如指南中所述,我已将 Microsoft.AspNetCore.All 替换为 Microsoft.AspNetCore.App。 Since the 2.1.0 version contains a lot of vulnerabilities, I am explicitly specifying the version of the package as 2.1.23 (latest for 2.1 according to NuGet).由于 2.1.0 版本包含很多漏洞,我明确指定 package 的版本为 2.1.23(根据 NuGet 最新为 2.1)。

The building of the project works fine as well as building the docker image.该项目的构建工作正常以及构建 docker 映像。 However, when I try to run the docker container, I get the following error:但是,当我尝试运行 docker 容器时,出现以下错误:

cord-notifier                 | It was not possible to find any compatible framework version
cord-notifier                 | The specified framework 'Microsoft.AspNetCore.App', version '2.1.23' was not found.
cord-notifier                 |   - Check application dependencies and target a framework version installed at:
cord-notifier                 |       /usr/share/dotnet/
cord-notifier                 |   - Installing .NET Core prerequisites might help resolve this problem:
cord-notifier                 |       https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
cord-notifier                 |   - The .NET Core framework and SDK can be installed from:
cord-notifier                 |       https://aka.ms/dotnet-download
cord-notifier                 |   - The following versions are installed:
cord-notifier                 |       2.1.20 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
cord-notifier exited with code 150

The docker base image that I am using is FROM mcr.microsoft.com/dotnet/core/sdk:2.2 I have tried switching to 2.1 as well but that does not do the trick either.我使用的 docker 基本映像是FROM mcr.microsoft.com/dotnet/core/sdk:2.2我也尝试过切换到 2.1,但这也不起作用。 I don't use the aspcore one because that does not have the SDK tools installed (such as dotnet).我不使用 aspcore 之一,因为它没有安装 SDK 工具(例如 dotnet)。

I tried listing the SDKs and runtime images on my machine and I can see that everything is installed there.我尝试在我的机器上列出 SDK 和运行时映像,我可以看到所有东西都安装在那里。

Microsoft.AspNetCore.All 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.23 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.23 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.22 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.23 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

And the SDKs和 SDK

2.1.300 [/usr/local/share/dotnet/sdk]
2.1.403 [/usr/local/share/dotnet/sdk]
2.1.701 [/usr/local/share/dotnet/sdk]
2.1.811 [/usr/local/share/dotnet/sdk]
2.2.207 [/usr/local/share/dotnet/sdk]
3.0.100 [/usr/local/share/dotnet/sdk]
3.1.101 [/usr/local/share/dotnet/sdk]
3.1.102 [/usr/local/share/dotnet/sdk]
3.1.402 [/usr/local/share/dotnet/sdk]
5.0.101 [/usr/local/share/dotnet/sdk]

I am running out of ideas on how to solve this.我已经没有关于如何解决这个问题的想法了。 Thank you in advance!先感谢您!

Edit: Added the dockerfile编辑:添加了 dockerfile

I use this docker file for the image itself.我将这个 docker 文件用于图像本身。 But for local dev, we have a different setup.但是对于本地开发人员,我们有不同的设置。

FROM dotnet-core-sdk-2.2-debug:latest AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY CordNotifier/cordfinance.webapi.utils.2.2.101.nupkg /Packages
COPY CordNotifier/cordfinance.webapi.utils.2.2.101.nupkg.sha512 /Packages
COPY CordNotifier/cordfinance.webapi.utils.nuspec /Packages
COPY CordNotifier/CordNotifier.csproj CordNotifier/
COPY CordNotifierDataModel/CordNotifierDataModel.csproj CordNotifierDataModel/
COPY Shared/Shared.csproj Shared/

 RUN dotnet restore CordNotifier/CordNotifier.csproj
#RUN dotnet list CordNotifier/CordNotifier.csproj package

# Copy everything else and build
COPY ./ ./
RUN dotnet publish CordNotifier/CordNotifier.csproj -c Debug -o out --no-restore

# Build runtime image
FROM dotnet-core-aspnet-2.1-debug:latest
WORKDIR /app

COPY --from=build-env /app/CordNotifier/out .

ENTRYPOINT ["dotnet", "CordNotifier.dll"]

where dotnet-core-sdk-2.2-debug:latest comes from dotnet-core-sdk-2.2-debug:latest来自哪里

FROM mcr.microsoft.com/dotnet/core/sdk:2.1

ENV ASPNETCORE_ENVIRONMENT=Development

# Global NuGet Configuration
COPY Packages/NuGet.config /root/.nuget/NuGet/NuGet.Config


# Populate Nuget Package Cache
COPY Packages Packages
RUN dotnet restore Packages/Packages.csproj; exit 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有这样的文件或目录,在 .net core 中运行控制台应用程序时无法在 docker 容器中找到 Python.exe - No such file or directory, Unable to find Python.exe in docker container when running console app in .net core 找不到请求的Net Framework数据提供程序 - Unable to find the requested Net Framework Data Provider 找不到请求的.Net Framework数据提供程序 - Unable to find the requested .Net Framework Data Provider ASP.Net无法找到.Net Framework Provider - ASP.Net Unable to find .Net Framework Provider .Net 1.1框架容器 - .Net 1.1 framework Container 找不到请求的.Net Framework数据提供程序-使用QuickBooks时出错 - Unable to find the requested .Net Framework Data Provider - Error using QuickBooks 找不到请求的.Net Framework数据提供程序。 它可能没有安装 - Unable to find requested .Net framework data provider. It may not be installed 找不到请求的.Net Framework数据提供程序。 它可能没有安装 - Unable to find the requested .Net Framework Data Provider. It may not be installed 错误-无法找到请求的.net Framework数据提供程序 - error - unable to find requested .net framework data provider 在服务器上找不到请求的.Net Framework数据提供程序错误 - Unable to find the requested .Net Framework Data Provider error on server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM