“ContainerBuildAndLaunch” 任务意外失败

huangapple go评论108阅读模式
英文:

The "ContainerBuildAndLaunch" task failed unexpectedly

问题

我正在创建一个使用c#、.Net 7和启用docker的ASP.Net Core Web API。当我尝试使用IISExpress运行它时,它运行得很顺利。但是,如果我尝试在docker中运行它,我会遇到以下错误。


错误 MSB4018 "ContainerBuildAndLaunch" 任务意外失败。
System.IO.FileNotFoundException: 无法加载文件或程序集 "Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 或其依赖项之一。系统找不到指定的文件。
文件名: "Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" at Microsoft.VisualStudio.Containers.Tools.Common.Client.DockerPathHelper.FindDockerCliPath()

我尝试将"Microsoft.Win32.Registry"添加到我的包中,但没有成功。感谢任何帮助。

英文:

I'm creating an ASP.Net Core Web API with c#, .Net 7 and docker enabled. When I try to run it using IISExpress, it works great. However, if I try to run it in docker I get below error.


Error 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' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at Microsoft.VisualStudio.Containers.Tools.Common.Client.DockerPathHelper.FindDockerCliPath()


I tried adding "Microsoft.Win32.Registry" to my packages but no luck. Any help is appreciated.

Thank you!

答案1

得分: 2

我遇到了同样的问题。将Microsoft.VisualStudio.Azure.Containers.Tools.Targets的NuGet包降级至1.11.1后,它开始提供实际有用的错误消息。主要的错误消息是我需要启用文件共享(Docker Desktop Settings/Resources/File Sharing)以及我的项目文件夹和C:\Microsoft\Xamarin\NuGet,尽管最终我只是添加了C:\以覆盖所有内容。

它还说我需要将我的Dockerfile从根目录(.sln所在的位置)移动到项目目录(.csproj所在的位置)。

现在它正常运行。甚至可以升级回1.15,它仍然正常工作。如果较新的NuGet版本能像旧版本一样提供有用的错误信息就好了...

英文:

I ran into this same problem. Downgrading the NuGet package for Microsoft.VisualStudio.Azure.Containers.Tools.Targets down to 1.11.1, it started giving me actual USEFUL error messages. The main one being I needed to turn on file sharing (Docker Desktop Settings/Resources/File Sharing) for my project folder and C:\Microsoft\Xamarin\NuGet, though ultimately I just added C:\ to cover everything.

It also said I needed to move my Dockerfile from the root directory (where .sln resides) to the project directory (where .csproj resides).

Now it runs fine. I was even able to upgrade back to 1.15 and it still worked. Would be nice if the newer NuGet versions gave useful errors like the old ones...

huangapple
  • 本文由 发表于 2023年2月10日 04:22:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75404043.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定