microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
192 stars 6 forks source link

[BUG] Can't attach debuger to simulator when build config is customized #1072

Closed espritm closed 2 weeks ago

espritm commented 3 weeks ago

Describe the Issue

I am migrating from .Net7 to .Net8 a MAUI application project. So I need to migrate from VS For Mac to VS Code too.

I have several build configurations, DebugEV1, DebugEV2 (and other for prod and release..). But I cannot use them successfully is VS Code.

In debug mode, the breackpoints are not reached with iOS simulator. The debuger is not attached. Sometime, the debuger is attached, but is detached after 2 seconds after the splashscreen appear.

Was working perfectly with VS For Mac for years (Xamarin.Forms, then MAUI net6, net7, ...)

Steps To Reproduce

1 Create a new .NET MAUI Project 2 In the csproj, add the following line :

       <Configurations>DebugEV2</Configurations> 

3 Add the following launch.json :

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "DebugEV2",
            "type": "maui",
            "request": "launch",
            "preLaunchTask": "maui: Build",
            "configuration": "DebugEV2"
        },
        {
            "name": "Debug",
            "type": "maui",
            "request": "launch",
            "preLaunchTask": "maui: Build",
            "configuration": "Debug"
        }
    ]
}

4 Put an accessible breackpoint, for instance in the MainPage.xml.cs in the OnCounterClicked method. 5 Run and Debug the app on ios simulator with config Debug : OK the breakpoint is reached. 6 Run and Debug the app on ios simulator with config DebugEV2 : BUG : can't reach the breakpoint, the debuger is not attached.

Expected Behavior

The breakpoint should be reached. The debuger should always be attached.

Environment Information

Visual Studio Code Version: 1.88.0 (Universal) Commit: 5c3e652f63e798a5ac2f31ffd0d863669328dc4c Date: 2024-04-03T13:28:18.899Z (6 days ago) Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Darwin arm64 23.1.0

.NET MAUI extension v0.9.7

C# extension v2.23.15

C# Dev Kit v1.4.29

dotnet 8.0.203 | VS Bug 2046825

mauroa commented 3 weeks ago

Hi @espritm. This issue should be fixed by updating .NET MAUI to latest pre-release, as well as the C# extension. Could you please confirm? Thanks for your help.

espritm commented 3 weeks ago

Hi @mauroa Thanks a lot for your answer. I have upgraded to latest pre-released versions. I have removed bin and obj folders. Now the debuger is not lost (the debug bar still appears). But I still can't reach the breackpoint, see the picture below. Breackpoints are grey out and the message "No symbols have been loaded for this document." appears when I place the mouse on one of the breackpoints.

image

With "Debug" config, the breackpoints are still reached.

C# v2.26.13 (pre-release) C# Dev Kit v1.5.14 (pre-release) .NET MAUI v0.11.16 (pre-release)

github-actions[bot] commented 3 weeks ago

@mauroa, the 'needs-more-info' label has been removed upon receiving further response from the original bug filer.

emaf commented 2 weeks ago

@espritm to enable debugging for iOS you need to set the following property, otherwise the debug symbols won't be included in your app bundle:

    <PropertyGroup Condition="'$(Configuration)' == '<your custom configuration>'">
        <_BundlerDebug>true</_BundlerDebug>
    </PropertyGroup>

The iOS SDK sets this value to true by default for the Debug config.

I'm closing this, but feel free to reopen it if you keep experiencing this issue.