visual studio pair连接MAC时卡住



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

ISO模拟器在windows中启动,但显示"连接到mac....">

如果在VS中,我取消选择"远程模拟器到windows";选项是VS,然后ISO模拟器在mac VM上启动并加载VS应用程序很好,但我不想在mac上工作,因为这意味着我必须来回切换,这在做开发工作时是一个麻烦的噩梦

当我检查Xamarin。模拟器日志我注意到这个:

Startup:
arguments: --device=EBAB483F-D9AF-XXX-XXXX--mlaunch=/Users/XXX/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/16.2.1040/tools/bin/mlaunch --launchsim=//Users/XXX/Library/Caches/Xamarin/mtbs/builds/MauiApp1/e42ad46171c3031dfcf0c05e01b82061b90e7c77273501****/bin/Debug/net7.0-ios/iossimulator-x64/MauiApp1.app -argument=-monodevelop-port -argument=56435 -setenv=__XAMARIN_DEBUG_PORT__=56435 --sdkroot=/Applications/Xcode.app -h=172.31.**.** -ssh=XXX
version: 17.5.0.518 (430be4c76fa1617d1af209951047a425c391d38e)
Connection state changed:
State: Connecting
SSH Connect:
target: 172.XX.XXX.XX
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
at Renci.SshNet.Abstractions.SocketAbstraction.Connect(IPEndPoint remoteEndpoint, TimeSpan connectTimeout)
at Renci.SshNet.Session.SocketConnect(String host, Int32 port)
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.CreateAndConnectSession()
at Renci.SshNet.BaseClient.Connect()
at Xamarin.Simulator.Core.Protocol.SshNetworkClientConnection.ConnectSsh(Target target)
at Xamarin.Simulator.Core.Protocol.SshNetworkClientConnection.ConnectAsync(Target target, MessageTypes messageTypes)
at Xamarin.Simulator.Core.Protocol.SimulatorClient.ConnectAsync()
at Xamarin.Simulator.Windows.App.<ConnectAsync>d__16.MoveNext()
Connection state changed:
State: Disconnected
Exit:
Exit Code: 0

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

PS C:Usersx> ssh-add -l
The agent has no identities.
PS C:Usersx> ssh -p 50922 patrickhume@172.31.***
The authenticity of host '[172.31.***]:50922 ([172.31.***]: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.***]:50922' (ED25519) to the list of known hosts.
(patrickhume@172.31.*** Password:
Last login: 
XXX@Patricks-iMac-Pro ~ % ls
Desktop         Downloads       Movies          Pictures
Documents       Library         Music           Public

我也可以从mac vm连接到windows使用:

ssh -p 22 patrickhume@outlook.com@192.XXX

查看日志深度,我想知道Xamarin是否没有正确设置端口

//用户/patrickhume/图书馆/缓存/Xamarin/mtb/构建/MauiApp1/e42ad46171c3031dfcf0c05e01b82061b90e7c772735013ee3a8aae95dea2dbe/bin/调试/net7.0-ios/iossimulator-x64/MauiApp1。app -argument=-monodevelop-port -argument=52260 -setenv=XAMARIN_DEBUG_PORT=52260——sdkroot=/Applications/Xcode。应用程序- h = 172.31。XXX -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.XXXX, 
1>              SshPort=50922, 
1>              TcpPort=52443, 
1>              User=****, 
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:GitHubMauiApp1binDebugnet7.0-iosiossimulator-x64MauiApp1.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的答案

我甚至在tcp://localhost:2375上不带TLS的环境和暴露守护进程中添加了DOCKER_HOST,并使用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.***:50922";作为配对时的地址)

最后,我找到了一个解决方案,它就像将端口更改为端口22一样简单,当我查看VMware的Xamarin日志时,我能够解决这个问题,我注意到使用了端口22,所以当我设置我的docker mac VM运行或端口22时,就像这样

docker run -it 
--device /dev/kvm 
-e RAM=8 
-p 22:10022 
-v /tmp/.X11-unix:/tmp/.X11-unix 
-e "DISPLAY=${DISPLAY:-:0.0}" 
-e GENERATE_UNIQUE=true 
-e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' 
sickcodes/docker-osx:ventura

ISO模拟器工作在windows很好,不知道为什么使用不同的端口导致问题,我会理解如果它是防火墙问题,但我排除了这一点,所以也许ssh连接从mac到windows需要在端口22上,这似乎不太可能。鉴于我以前没有这个问题,我只能猜测,也许我的机器上有一些配置是不同的后格式与预格式,也许是Windows, vs, Xcode或MAC更新的结果。我想有一天工作,使用端口22是可以的,但仍然限制,如果这是唯一的端口我可以使用。在任何情况下,它是有效的,所以我希望这一天能帮助到别人

最新更新