-
Notifications
You must be signed in to change notification settings - Fork 227
Description
Visual Studio 2022 for Windows does not have functionality for debugging .Net Maui Mac Catalyst apps on a remote Mac host like you can for iOS development so I am currently building a VS Extension for my company (and public) that facilitates the transfer of the project over to a remote Mac host for building, debugging and launching the Mac Catalyst platform of our app, my extension is called Pair To Mac Catalyst.
I have everything working except connecting the debugger properly. I can connect to vsdbg and launch Maui Mac Catalyst app fine, but the debugger does not load the debug symbols, i.e. *.pdb files. I can't see modules in my modules window and I can't set breakpoints in VS 2022.
I have followed the instruction on Offroad Debugging of .NET Core on Linux OSX from Visual Studio.
My current launch.json config is as follows:
{
"version": "0.2.0",
"adapter": "C:\\<path-to>\\plink.exe",
"adapterArgs": "-pw pass host@ip ~/vsdbg/vsdbg",
"languageMappings": {
"C#": {
"languageId": "3F5162F8-07C6-11D3-9053-00C04FA302A1",
"extensions": [ "*" ]
}
},
"configurations": [
{
"name": ".NET MAUI Launch",
"type": "coreclr",
"request": "launch",
"program": "MauiApp1.app/Contents/MacOS/MauiApp1",
"args": [],
"cwd": "**/MauiApp1/bin/Debug/net9.0-maccatalyst/maccatalyst-arm64",
"justMyCode": false,
"requireExactSource": false,
"symbolSearchPath": "https://symbols.nuget.org/download/symbols;/**/MauiApp1/bin/Debug/net9.0-maccatalyst/maccatalyst-arm64/**/*.pdb",
"symbolOptions": {
"loadedOnlyIncluded": false,
"searchPaths": [
"https://symbols.nuget.org/download/symbols",
"**/MauiApp1/bin/Debug/net9.0-maccatalyst/maccatalyst-arm64/**/*.pdb",
],
"moduleFilter": {
"mode": "loadAllButExcluded",
"excludedModules": []
}
},
"sourceFileMap": {
"C:\\<local-project-path>": "/<mac-project-path>"
},
"logging": {
"trace": true,
"traceResponse": true,
"programOutput": true,
"exceptions": true,
"moduleLoad": true
}
}
]
}Note: I am using full paths in my real config so all the paths should be resolving correctly.
I am currently using the following command to at least get the debugger working correctly during development of my extension:
DebugAdapterHost.Launch /LaunchJson:"C:\<path-to>\MauiApp1\Properties\launch.json" /EngineGuid:541B8A8A-6081-4506-9F0A-1CE771DEBC04I noticed in my "Debug Adaptor Host Log" the following:
1> [DebugAdapter] --> C (setSymbolOptions-17): {"type":"request","command":"setSymbolOptions","arguments":{"symbolOptions":{"moduleFilter":{"mode":"loadOnlyIncluded","includedModules":[""]}}},"seq":17}So as I see it, the following is not overriding the default settings for the .Net Core for Unix engine \ 541B8A8A-6081-4506-9F0A-1CE771DEBC04 ...
"symbolSearchPath": "https://symbols.nuget.org/download/symbols;/**/MauiApp1/bin/Debug/net9.0-maccatalyst/maccatalyst-arm64/**/*.pdb",
"symbolOptions": {
"loadedOnlyIncluded": false,
"searchPaths": [
"https://symbols.nuget.org/download/symbols",
"**/MauiApp1/bin/Debug/net9.0-maccatalyst/maccatalyst-arm64/**/*.pdb",
],
"moduleFilter": {
"mode": "loadAllButExcluded",
"excludedModules": []
}
},When I set a breakpoint, I also get the following response from my remote vsdbg instance.
1> [DebugAdapter] <-- R (addBreakpoint-25) [78 ms]: {"type":"response","request_seq":25,"success":true,"command":"addBreakpoint","body":{"breakpoint":{"id":4,"verified":false,"message":"No symbols have been loaded for this document."}},"seq":35}Does your team have any insight on how to load modules\symbols on OSX over SSH\VSDBG for Maui Mac Catalyst apps?
While I am at it, what would be the correct way to set the config for IVsDebugger4 so I don't have to create a launch.json file on the fly and run a launch command? Currently I am playing around with the following but get an unknown error:
Guid guidUnixDebugEngine = Guid.Parse("541B8A8A-6081-4506-9F0A-1CE771DEBC04");
IntPtr pguidDebugEngine = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidUnixDebugEngine));
Marshal.StructureToPtr(guidUnixDebugEngine, pguidDebugEngine, false);
VsDebugTargetInfo4[] pDebugTargets = new VsDebugTargetInfo4[1];
// pDebugTargets[0].bstrExe = "MauiApp1";
// pDebugTargets[0].bstrRemoteMachine = $"{_macBridgeService.MacConnection.IpAddress}:{4024}";
pDebugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
pDebugTargets[0].guidLaunchDebugEngine = guidUnixDebugEngine;
pDebugTargets[0].dwDebugEngineCount = 1;
pDebugTargets[0].pDebugEngines = pguidDebugEngine;
pDebugTargets[0].fSendToOutputWindow = true;
pDebugTargets[0].bstrRemoteMachine = _macBridgeService.MacConnection.IpAddress;
pDebugTargets[0].bstrPortName = "4024";
pDebugTargets[0].bstrOptions = MinifyJson(LaunchConfig.GetConfig());
VsDebugTargetProcessInfo[] pLaunchResults = new VsDebugTargetProcessInfo[1];
_debugger4.LaunchDebugTargets4(1, pDebugTargets, pLaunchResults);