Thread overview
Compile and run in Win10-VSCode
Sep 25, 2020
Paul
Sep 25, 2020
Imperatorn
Sep 25, 2020
Aldo
September 25, 2020
Hi Community,

I'm Win10: I have VSCode installed.  I have DMD installed and can compile examples from a Win CMD console.

1) How do I compile and run from within VSCode?
2) VSCode Extensions:
      Do I need them?
      One kept generating errors and a note said it was not under active development so I
         uninstalled it.
      The remaining two are by WebFreak.  Are they working?  Do I need them?

Thanks for your time.
September 25, 2020
On Friday, 25 September 2020 at 13:38:56 UTC, Paul wrote:
> Hi Community,
>
> I'm Win10: I have VSCode installed.  I have DMD installed and can compile examples from a Win CMD console.
>
> 1) How do I compile and run from within VSCode?
> 2) VSCode Extensions:
>       Do I need them?
>       One kept generating errors and a note said it was not under active development so I
>          uninstalled it.
>       The remaining two are by WebFreak.  Are they working?  Do I need them?
>
> Thanks for your time.

The code-d extension is awesome. Use it. About building and running, there should be an associated code-D tasks. Otherwise, just type dub. Did you create your project using dub init?
September 25, 2020
On Friday, 25 September 2020 at 13:38:56 UTC, Paul wrote:
> Hi Community,
>
> I'm Win10: I have VSCode installed.  I have DMD installed and can compile examples from a Win CMD console.
>
> 1) How do I compile and run from within VSCode?
> 2) VSCode Extensions:
>       Do I need them?
>       One kept generating errors and a note said it was not under active development so I
>          uninstalled it.
>       The remaining two are by WebFreak.  Are they working?  Do I need them?
>
> Thanks for your time.

In VSCode the best way to work is by using dub directly. You should have a terminal on the bottom, just type dub it will compile & run your app. Or if you want you can use the vscode build system, create a new task in your project (Ctrl+Shift+B) and add the following task for example:

{
        "label": "Compile and run",
        "type": "shell",
        "command":"dub",
        "group": {
          "kind": "build",
          "isDefault": true
        }
 }



For debugging (on windows), I use the "C/C++" extension and the F5 key. It will create a launch.json file in "C:/projectPath/.vscode/launch.json". You just need to add something like that in this file:

        {
            "name": "(Windows) Debug",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/yourexecutable.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false
       }

Don't forget to enable breakpoints everywhere in your VSCode settings (Allow Breakpoints Everywhere checkbox).