Skip to content

Debugging a single file dotnet app with command line arguments is very unclear/obtuse #8920

@Mattwmaster58

Description

@Mattwmaster58

Is your feature request related to a problem? Please describe.

The happy path for single file debugging is just clicking the button: https://code.visualstudio.com/docs/csharp/debugging#_debug-with-editor-debugrun-buttons

This apparently all falls apart when you want to pass command line arguments to your own program.

Describe the solution you would like

Better documentation/out of the box support for passing command line args. I think single file apps are great for dotnet, and better supporting them in VSCode will lead to better adoptoin as well.

Describe alternatives you've considered

Blindly stumbling around the docs trying to get this to work - sort of annoying.

Additional context

I tried a lot of things, eventually ended up with with a custom prelaunch task to build the app:

    "tasks": [
        {
            "label": "build myfile",
            "type": "shell",
            "command": "dotnet",
            "args": [
                "build",
                "${workspaceFolder}\\myfile.cs",
                "--output",
                "${env:TEMP}\\myfile"
            ],
            "group": "build",
            "problemMatcher": "$msCompile",
            "presentation": {
                "reveal": "silent",
                "panel": "dedicated",
                "close": true
            }
        }
    ]

launch.json:

    "configurations": [
        {
            "name": "myfile.cs",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build myfile",
            "program": "${env:TEMP}\\myfile.dll",
            "args": [all the args to pass here]
        }]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions