我能够将Microsoft Visual Studio 2022版本(17.5.3)连接到Ventura版本13.3 Mac OSX,在Sickcodes Docker图像中运行,我从来没有遇到过任何问题,直到我不得不重新格式化我的PC,从那时起,我遇到了一点麻烦。
ISO模拟器在Windows中启动,但被卡住说“连接到Mac...”
如果在VS中我取消选择“远程模拟器到Windows”选项是VS,那么ISO模拟器将在Mac VM上启动并加载VS应用程序,但我不想在Mac上工作,因为这意味着我必须来回翻转,当做开发工作时,这是一场噩梦
当我检查Xamarin.Simulator日志时,我注意到:
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连接到mac从windows没有问题使用powershell
PS C:\Users\x> ssh-add -l
The agent has no identities.
PS C:\Users\x> 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是否没有正确设置端口
//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.XXX -帕特里克·休谟
然而,ssh端口在连接到vm时被设置,如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:\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的答案
我甚至在环境中添加了DOCKER_HOST,并在tcp://localhost:2375上不使用TLS添加了Expose守护进程,并使用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”作为地址)
1条答案
按热度按时间hpxqektj1#
最后,我找到了一个解决方案,它就像将端口更改为端口22一样简单,当我查看适用于VMware的Xamarin日志时,我能够解决这个问题,我注意到使用端口22,所以当我设置我的docker mac虚拟机运行或端口22时,就像这样
ISO模拟器在Windows中工作正常,不知道为什么使用不同的端口会导致问题,如果是防火墙问题,我会理解,但我排除了这一点,所以也许从Mac到Windows的ssh连接需要在端口22上,这似乎不太可能。鉴于我以前没有这个问题,我只能猜测,也许我的机器上有一些配置是不同的post format vs pre-format,也许是Windows、VS、Xcode或MAC更新的结果。我希望有一天能解决这个问题,因为使用端口22是可以的,但如果这是我唯一可以使用的端口,那就仍然有限制。无论如何,它都能工作,所以我希望这有一天能帮助到别人