How do I forward command line arguments when debugging into a dotnet console program? #4256
-
Greetings, I am trying to pass command line arguments into a C# dotnet8 console application and I haven't been able to figure it out. I would think the appropriate way would be to inject them via the generated docker-run task in tasks.json using one of the documented properties here:
I have noticed that in the provided dockerfile that the ENTRYPOINT line doesn't seem to have any effect or adding CMD statements there.
Again any pointers are greatly appreciated, I am running this on OSX Sonoma Apple M3. I am aware that I can use the env argument inside dockerRun but I want to also be able to specify command line arguments. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
For debugging, we don't actually launch the entrypoint--we start the container with a do-nothing command so it stays up but isn't doing anything. From there, we start VSDBG, and instruct VSDBG to start your app. This way, you can debug startup code. Consequently, to get command line arguments to your app, you have to instruct VSDBG to do it, which can be done in {
"version": "0.2.0",
"configurations": [
{
"name": "Docker .NET Launch",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"netCore": {
"appProject": "${workspaceFolder}/NetConsole8.csproj"
},
"args": [ // Add this section here
"/app/bin/Debug/net8.0/NetConsole8.dll", // The path to your app will be something like /app/bin/Debug/net8.0/YourAppName.dll
"-Hello", // First argument
"-World" // Second argument
]
}
]
} The |
Beta Was this translation helpful? Give feedback.
For debugging, we don't actually launch the entrypoint--we start the container with a do-nothing command so it stays up but isn't doing anything. From there, we start VSDBG, and instruct VSDBG to start your app. This way, you can debug startup code.
Consequently, to get command line arguments to your app, you have to instruct VSDBG to do it, which can be done in
.vscode/launch.json
by adding properties like this to the "Docker .NET Launch" configuration: