简体   繁体   English

Docker 构建:“ContainerBuildAndLaunch”任务意外失败。 无法加载文件或程序集“Microsoft.Win32.Registry

[英]Docker Build : The "ContainerBuildAndLaunch" task failed unexpectedly. Could not load file or assembly 'Microsoft.Win32.Registry

I am trying to build my.Net 6.0 API Project in Visual studio 2022, and I get the following error.我正在尝试在 Visual Studio 2022 中构建 my.Net 6.0 API 项目,但出现以下错误。

MSB4018 The "ContainerBuildAndLaunch" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'  user declined directory sharing

Even though project target OS Framework - Linux, it is looking out for Microsoft.Win32.Registry for some reason.尽管项目目标操作系统框架 - Linux,但出于某种原因它正在寻找Microsoft.Win32.Registry Any direction will be highly appreciated.任何方向将不胜感激。

Docker file Docker 档案

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. #See https://aka.ms/containerfastmode以了解 Visual Studio 如何使用此 Dockerfile 构建您的图像以加快调试速度。

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["BPBComputerGadgets.ProductsAPI/BPBComputerGadgets.ProductsAPI.csproj", "BPBComputerGadgets.ProductsAPI/"]
RUN dotnet restore "BPBComputerGadgets.ProductsAPI/BPBComputerGadgets.ProductsAPI.csproj"
COPY . .
WORKDIR "/src/BPBComputerGadgets.ProductsAPI"
RUN dotnet build "BPBComputerGadgets.ProductsAPI.csproj" -c Release -o /app/build

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

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

The issue was the user declined directory sharing .问题是user declined directory sharing Opened the docker desktop->settings->Resources->File Sharing and Add the folders -> Apply and restart.打开docker桌面->设置->资源->文件共享和添加文件夹->应用并重启。

在此处输入图像描述

暂无
暂无

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

相关问题 'Microsoft.Win32.Registry'是'type',但用作'变量' - 'Microsoft.Win32.Registry' is a 'type' but is used like a 'variable' 错误:无法从 .NET Framework 控制台应用程序使用的 .NET 标准库加载文件或程序集“Microsoft.Win32Registry” - Error: Could not load file or assembly 'Microsoft.Win32Registry' from .NET Standard Library Consumed by .NET Framework Console App Microsoft.Win32.Registry的GetValue不使用默认值 - Microsoft.Win32.Registry's GetValue Doesn't Use Default Value 无法加载文件或程序集Microsoft.Win32.Primitives,Version = 4.0.0.0 - Could not load file or assembly Microsoft.Win32.Primitives, Version=4.0.0.0 如何修复错误参数3:c#中无法从'System.DateTime'转换为'Microsoft.Win32.Registry ValueOptions' - how to fix error Argument 3: cannot convert from 'System.DateTime' to 'Microsoft.Win32.Registry ValueOptions' in c# “ XamlCTask”任务意外失败。 该怎么办? - The “XamlCTask” task failed unexpectedly. What to do? “LinkAssemblies”任务意外失败。 xamarinandroidException:错误 XA2006:无法解析引用 - The “LinkAssemblies” task failed unexpectedly. xamarinandroidException: error XA2006: could not resolve reference 无法加载文件或程序集 Microsoft.Build.Utilities.Core - Could not load file or assembly Microsoft.Build.Utilities.Core “Csc”任务意外失败无法从程序集 mscorlib Version=4.0.0.0 加载类型 System.ValueTuple 3, - The “Csc” task failed unexpectedly Could not load type System.ValueTuple 3 from assembly mscorlib Version=4.0.0.0, 无法加载文件或程序集“Microsoft.Build.Framework”(VS 2017) - Could not load file or assembly 'Microsoft.Build.Framework'(VS 2017)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM