4

Just been reading this article from Scott Allen.

The approach to specify command line arguments to .net core seems intersing, but how do we pass those arguments from VS Code when running with debugger (Normally using F5 command if launch.json is setup)?

e.g dotnet run dropdb migratedb seeddb

3
  • 1
    Have you tried adding "args": ["dropdb", "migratedb", "seeddb"] to your launch.json configuration? Commented Dec 16, 2016 at 22:57
  • @MattBierner Thanks, that was simple and works perfectly. Commented Dec 17, 2016 at 9:37
  • Glad to hear. I've posted the comment as an answer so that you can close this question out Commented Dec 19, 2016 at 23:27

1 Answer 1

11

Copying over answer from comment


Note: launch.json is found in the .vscode folder under your project.

In your launch.json, try adding:

"args": ["dropdb", "migratedb", "seeddb"]

to the target launch configuration.

Providing Context Inside launch.json

Your launch.json will contain an empty args element by default which looks something like:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/<YourProjName>/bin/Debug/net6.0/YourProjName.dll",
            "args": [],
            "cwd": "${workspaceFolder}/<YourProjName>",
            "stopAtEntry": false,
            "serverReadyAction": {
            .
            .
            .
            // launch.json file continues...
Sign up to request clarification or add additional context in comments.

1 Comment

When I write "type": "dotnet", linter said Property args is not allowed. at line "args": []. So I just want to warn for everyone that to use args the type must be coreclr.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.