dotnet / dotnet/vscode-csharp

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

Open
#8,920 6 comments 2 reactions 0 assignees View on GitHub
Debugger Feature - Run File untriaged
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
18h 40m
Merged PRs (30d)
31

Description

## 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:

```json
"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:
```json
"configurations": [
{
"name": "myfile.cs",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build myfile",
"program": "${env:TEMP}\\myfile.dll",
"args": [all the args to pass here]
}]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.