我有一个.NET 7应用程序在Ubuntu机器上的Linux docker容器中运行。我无法将Visual Studio(在Windows 11上)连接到我的应用程序。我可以连接到其他Ubuntu机器上Docker内的其他.NET应用程序。
我得到这个错误:无法启动调试适配器'coreclr'. VsDbgRemoteUnixLauncher只支持远程Unix计算机!
Attach-to-process向导可以看到容器和这些容器中的进程,所以ssh连接似乎没有问题。
我在网上找不到关于这个错误的任何东西。
额外信息:运行此命令后,X1 m0n1x适配器主机日志的输出
1> DebugAdapterHost version: 17.6.10530.1 commit:a8b80a80533cc2b91039497e292d6997b60501a6
1> ERROR: Failed to launch debug adapter!
DebugAdapterLaunchException: Failed to launch debug adapter. Additional information may be available in the output window.
Failure Location: LaunchingProcess
Inner Exception:
InvalidOperationException: VsDbgRemoteUnixLauncher only supports remote Unix machines!
Microsoft.VisualStudio.Debugger.VsDbg.Integration.AdapterLauncher.VsDbgRemoteUnixLauncher.Microsoft.VisualStudio.Debugger.DebugAdapterHost.Interfaces.IAdapterLauncher.LaunchAdapter(IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.AdapterHosting.DebugAdapterProcessConnection..ctor(ConfigurationWrapper configuration, IDiagnosticLogger log, IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop, IAdapterLauncher launcher)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.AdapterHosting.DebugAdapterHostFactory.CreateDebugAdapterHost(ConfigurationWrapper configuration, IDiagnosticLogger log, ExtensibilityManager extensibilityManager, IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop, Boolean registerStandardHandlers, DebugProtocolOptions options, Action`1 syncRequestErrorHandler)
1> ERROR: Unexpected error
DebugAdapterLaunchException: Failed to launch debug adapter. Additional information may be available in the output window.
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.AdapterHosting.DebugAdapterHostFactory.CreateDebugAdapterHost(ConfigurationWrapper configuration, IDiagnosticLogger log, ExtensibilityManager extensibilityManager, IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop, Boolean registerStandardHandlers, DebugProtocolOptions options, Action`1 syncRequestErrorHandler)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.AdapterHosting.DebugAdapterHostFactory.CreateDebugAdapterHost(DebuggedProcess process, IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.Engine.Implementation.DebuggedProcess.StartDebugAdapter(IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop)
Failure Location: LaunchingProcess
Inner Exception:
InvalidOperationException: VsDbgRemoteUnixLauncher only supports remote Unix machines!
Microsoft.VisualStudio.Debugger.VsDbg.Integration.AdapterLauncher.VsDbgRemoteUnixLauncher.Microsoft.VisualStudio.Debugger.DebugAdapterHost.Interfaces.IAdapterLauncher.LaunchAdapter(IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.AdapterHosting.DebugAdapterProcessConnection..ctor(ConfigurationWrapper configuration, IDiagnosticLogger log, IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop, IAdapterLauncher launcher)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.AdapterHosting.DebugAdapterHostFactory.CreateDebugAdapterHost(ConfigurationWrapper configuration, IDiagnosticLogger log, ExtensibilityManager extensibilityManager, IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop, Boolean registerStandardHandlers, DebugProtocolOptions options, Action`1 syncRequestErrorHandler)
1> ERROR: Failed to launch debug adapter. Additional information may be available in the output window.
VsDbgRemoteUnixLauncher only supports remote Unix machines!
字符串
2条答案
按热度按时间x4shl7ld1#
我让它工作!我通过使用WebId记录Visual Studio在docker主机上执行的命令来解决这个问题。通过手动执行这些命令,我有了更多关于错误的信息。
在我的例子中,这个命令失败了:
字符串
它失败了,因为SSH用户的主目录中用于远程调试的目录.docker由root所有。将所有者更改为正确的用户解决了我的问题。
对于任何阅读这篇文章的人来说,有一个类似的问题,但不是同一个问题:安装并启动blog d,在/etc/audit/rules.d/audit.rules的末尾添加这些规则:
型
然后运行这些命令:
型
尝试在VS中附加,然后执行:
型
这将显示该用户执行的所有命令。可能最后一个命令将指示问题。
kcwpcxri2#
假设基础映像是
mcr.microsoft.com/dotnet/aspnet:7.0-alpine
,容器中uname
的结果是Linux
,这意味着容器本身应该是remote debugging与Visual Studio兼容的Unix环境。作为一种解决方法,您可以尝试在Docker之外运行应用程序,以隔离问题是Docker特定的还是与应用程序的配置相关的。
我只能找到这个other case,它指出:
View -> Other Windows -> Command Window
)并输入DebugAdapterHost.Logging /On /OutputWindow
来获取其他日志。如果切换到Show output from: Debug Adapter Host Log
,这将在输出窗格中删除其他日志。”在Docker和远程调试的上下文中,防火墙也可能是一个潜在的问题。即使应用程序在Alpine Linux基础映像上的Docker容器内运行,运行Visual Studio的Windows 11计算机与远程Ubuntu计算机上的Docker容器之间的网络通信也会通过主机的网络堆栈,这取决于主机的防火墙设置。
字符串
使用Visual Studio远程调试.NET应用程序时,可能会涉及多个端口,具体取决于所使用的配置和服务。请确保端口22(或您配置的SSH端口)对Ubuntu计算机上的传入连接打开。
型
找出VsDbg正在使用的端口,并确保它是打开的。如果它是动态的,您可能需要设置一个特定的端口,并在启动Docker容器时公开它。
型
确保Docker run命令公开了必要的端口,例如,
-p 8080:80
将容器上的端口80公开给主机上的端口8080。OP's solution使用
auditd
记录Docker主机上Visual Studio执行的命令。您可以在Chris Binnie的2018年文章“Auditing Docker Containers in a DevOps Environment”中看到它。
型
这个问题最终与文件所有权问题有关,而不是直接与Docker或Visual Studio配置相关。
此问题被跟踪到SSH用户主目录中
.docker
目录的权限问题。更改.docker
目录的所有权解决了此问题。