JaneySprings / DotNet.Meteor

A VSCode extension that can run and debug .NET apps (Xamarin, MAUI, Avalonia)
https://marketplace.visualstudio.com/items?itemName=nromanov.dotnet-meteor
MIT License
269 stars 10 forks source link

Custom Configurations Unsupported #116

Closed ChrisMonson closed 2 months ago

ChrisMonson commented 2 months ago

Hello, and thank you for this fantastic extension. I've been running into an issue with defining custom configurations beyond Debug and Release for my project.

In my use case I have two separate debug configurations, Debug, used for local debugging, and Debug_Staging that defines some constants that let me debug against our staging environment.

Changing the active configuration in the status bar of VS Code always results in the Debug configuration being built, and the configuration selection in the status bar that I believe is associated with DotNet.Meteor only ever gives the options of Debug or Release.

I have attempted to handle this configuration change via VS Code Tasks using args to change the configuration being built. This works to build that configuration, however DotNet.Meteor still tries to launch the last build completed with Debug (/bin/Debug/) instead of Debug_Staging (/bin/Debug_Staging/).

I tried to work around this by changing the build path for Debug_Staging to build into /bin/Debug, which works, however after the build completes and launches it hangs on the app splash screen indefinitely with no errors and nothing of particular relevance logged. Building with Debug instead of Debug_Staging works fine. Additionally building and running the configuration through the dotnet cli using dotnet build -t:Run -f net8.0-ios -c Debug_Staging; also works properly using the correct configuration.

This has left me at a bit of a standstill as I'm not sure if there is any further I can take this in working around the issue. I'm hoping you can tell me that I'm just missing something simple or doing this all wrong 😂.

JaneySprings commented 2 months ago

Hi, @ChrisMonson ! I did not know that you can create custom configuration in csproj, except Debug or Release =) Yeah, .NET Meteor uses only Debug or Release folder for detecting the application:

https://github.com/JaneySprings/DotNet.Meteor/blob/46dcf6936dccf952545dbe8124ff5f34ce347860/src/DotNet.Meteor.Common/ProjectExtensions.cs#L84

I have a suggestion. I can create an option in the launch.json for specifying custom configuration, for example:

 "configurations": [
        {
            "name": ".NET Meteor Debugger (custom config)",
            "type": "dotnet-meteor.debugger",
            "request": "launch",
            "preLaunchTask": "dotnet-meteor: Build",
            "configuration": "Debug_Staging",
        }
    ]

it will be nice for you?

ChrisMonson commented 2 months ago

Awesome! I know that it's a little bit of a niche problem, but custom configurations can be really nice for having applications build in different ways for different situations. That sounds like a fantastic solution to me. I think that would solve all of the issues I have.

JaneySprings commented 2 months ago

OK! I've already fixed it, but it's too late today. Tomorrow I will check that everything is working and I will release a new version

ChrisMonson commented 2 months ago

You are amazing. Thank you so much!

JaneySprings commented 2 months ago

Hi, I have fixed this bug in the 5.3.1 version! You can use the following workaround:

tasks.json - change default value, provided by .NET Meteor

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "dotnet-meteor.task",
            "target": "build",
            "problemMatcher": [
                "$dotnet-meteor.problemMatcher"
            ],
            "label": "dotnet-meteor: Build",
            "args": [
                "-p:Configuration=Debug_Staging"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

launch.json - specify custom configuration

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Meteor Debugger",
            "type": "dotnet-meteor.debugger",
            "request": "launch",
            "configuration": "Debug_Staging",
            "preLaunchTask": "dotnet-meteor: Build",
        }
    ]
}
ChrisMonson commented 2 months ago

I just updated the .Net Meteor extension and gave this a try and it works perfectly. Thank you so much for this amazingly quick update! I don't believe I've ever submitted a bug and had it fixed and deployed in under 24 hours before 😀.

maonaoda commented 2 months ago

@JaneySprings runtime had been removed,how can i continue to use it? image

JaneySprings commented 2 months ago

Hi @maonaoda ! Yes, I have rewritten this part and add more settings for the debugger launch.

You can specify path to your x64 application in the launch.json (Preferred way):

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "iossimulator-x64",
            "type": "dotnet-meteor.debugger",
            "request": "launch",
            "program": "${workspaceFolder}/bin/Debug/net8.0-ios/iossimulator-x64/MauiTestApp.app",
            "preLaunchTask": "dotnet-meteor: Build"
        }
    ]
}

Or you can change your device settings in the launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "iossimulator-x64",
            "type": "dotnet-meteor.debugger",
            "request": "launch",
            "device": {
                "serial": "${command:dotnet-meteor.activeDeviceSerial}",
                "runtime_id": "iossimulator-x64",
                "platform": "ios",
                "is_mobile": true,
                "is_emulator": true,
            },
            "preLaunchTask": "dotnet-meteor: Build"
        }
    ]
}

I also want to make a note of all the options in the documentation or readme.

JaneySprings commented 2 months ago

Documentation link: https://github.com/JaneySprings/DotNet.Meteor/wiki/How-to-fix-the-error:-clang-exited-with-code-1