visual studio 对 mac 卡在连接上(不是重复的)

问题描述 投票:0回答:0

这似乎是一个重复的问题,但实际上并非如此,这就是为什么

我能够将 Microsoft Visual Studio 2022 ver (17.5.3) 连接到在 sickcodes docker 映像中运行的 Ventura ver 13.3 Mac OSX,并且在我不得不重新格式化我的电脑之前我从来没有遇到过任何问题,从那时起我遇到了一些问题一堵墙。

ISO 模拟器在 Windows 中启动,但卡住说“正在连接到 mac...”

如果在 VS 中我取消选择“远程模拟器到 Windows”选项是 VS,那么 ISO 模拟器在 mac VM 上启动并加载 VS 应用程序正常,但我不想在 mac 上工作作为手段我必须来回翻转,在进行开发工作时这是一场麻烦的噩梦

当我检查 Xamarin.Simulator 日志时,我注意到:

startup:
    arguments: --device=EBAB483F-D9AF-449B-B1CA-C747F9125C0A --mlaunch=/Users/patrickhume/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/16.2.1040/tools/bin/mlaunch --launchsim=//Users/patrickhume/Library/Caches/Xamarin/mtbs/builds/MauiApp1/e42ad46171c3031dfcf0c05e01b82061b90e7c772735013ee3a8aae95dea2dbe/bin/Debug/net7.0-ios/iossimulator-x64/MauiApp1.app -argument=-monodevelop-port -argument=52260 -setenv=__XAMARIN_DEBUG_PORT__=52260 --sdkroot=/Applications/Xcode.app -h=172.31.114.144 -ssh=patrick hume 
    version: 17.5.0.518 (430be4c76fa1617d1af209951047a425c391d38e)
Connection state changed:
    State: Connecting
SSH Connect:
    target: 172.31.114.144
Using SSH pass phrase
Warning: Error during connecting
System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it

所以问题似乎与 ssh 连接有关,但我可以使用 ssh 从 Windows 连接到 mac,使用 powershell 没有问题

PS C:\Users\ASUS> ssh-add -l
The agent has no identities.
PS C:\Users\ASUS> ssh -p 50922 [email protected]
The authenticity of host '[172.31.114.144]:50922 ([172.31.114.144]:50922)' can't be established.
ED25519 key fingerprint is SHA256:+6********************.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[172.31.114.144]:50922' (ED25519) to the list of known hosts.
([email protected]) Password:
Last login: Thu Mar 30 17:06:26 2023
patrickhume@Patricks-iMac-Pro ~ % ls
Desktop         Downloads       Movies          Pictures
Documents       Library         Music           Public

我还可以使用以下方法从 mac 虚拟机连接到 windows:

ssh -p 22 [email protected]@192.168.253.1

看日志,疑惑是不是Xamarin没有设置好端口

//Users/patrickhume/Library/Caches/Xamarin/mtbs/builds/MauiApp1/e42ad46171c3031dfcf0c05e01b82061b90e7c772735013ee3a8aae95dea2dbe/bin/Debug/net7.0-ios/iossimulator-x64/MauiApp1.app -argument=-monodevelop-port -argument=52260 - setenv=XAMARIN_DEBUG_PORT=52260 --sdkroot=/Applications/Xcode.app -h=172.31.114.144 -ssh=patrick hume

但是,连接到虚拟机时正在设置 ssh 端口 如 VS 的终端窗口日志中所示:

1>------ Build started: Project: MauiApp1, Configuration: Debug Any CPU ------
1>Executing SayHello Task to establish a connection to a Remote Server. 
1>          Properties: 
1>              SessionId=e42ad46171c3031dfcf0c05e01b82061b90e7c772735013ee3a8aae95dea2dbe, 
1>              Addresss=172.31.114.144, 
1>              SshPort=50922, 
1>              TcpPort=52443, 
1>              User=patrick hume, 
1>              AppName=MauiApp1,
1>              VisualStudioProcessId=38828,
1>              ContinueOnDisconnected=False
1>Detected signing identity:
1>  Bundle Id: com.companyname.mauiapp1
1>  App Id: com.companyname.mauiapp1
1>Skipping analyzers to speed up the build. You can execute 'Build' or 'Rebuild' command to run analyzers.
1>MauiApp1 -> D:\GitHub\MauiApp1\bin\Debug\net7.0-ios\iossimulator-x64\MauiApp1.dll
1>Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
......

我排除了防火墙,因为我在 mac 和 windows 上禁用了它,我添加了 ssh 作为例外:

New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

即使我完全禁用 Windows 防火墙和我的防病毒软件也没有任何区别。

使用 stackoverflow 的答案

我什至在没有 TLS 的情况下将 DOCKER_HOST 添加到环境中并在 tcp://localhost:2375 上公开守护进程,并使用 netstat -anb 来验证它是否正在运行并在预期的端口上侦听

其他建议涉及更新 VS 或 Xcode-(甚至降级)但我之前使用的是 Xcode 14.2 版并且我使用的是最新版本的 VS

我尝试使用一些 .wslconfig 配置设置,例如:

# Network host settings that enable the DNS server used by WSL 2. This example changes the hostname, sets generateHosts to false, preventing WSL from the default behavior of auto-generating /etc/hosts, and sets generateResolvConf to false, preventing WSL from auto-generating /etc/resolv.conf, so that you can create your own (ie. nameserver 1.1.1.1).
[network]
hostname = DemoHost
generateHosts = false
generateResolvConf = false
# Turn off default connection to bind WSL 2 localhost to Windows localhost
localhostforwarding=true

但这感觉像是在转移注意力,所以我恢复到原来的配置设置:

[wsl2]
nestedVirtualization=true

我查看了 sshd_config 文件,但考虑到我之前不必更改这些文件,这有点超出我的专业知识范围,所以我没有管它

所以现在我没主意了,我相信这不是使用 VM、Docker 或 Sickcodes 的问题,因为我以前有过这个工作。所以如果有人有什么请告诉我?

注意:docker 将 Ubuntu 集成设置为默认设置,wsl 使用 Ubuntu 作为其默认发行版,我使用的是 WSL 2。VS 能够与 mac 配对没有问题(我使用“172.31.114.144:50922”作为地址配对)

windows docker macos docker-machine sickcodes
© www.soinside.com 2019 - 2024. All rights reserved.