How to debug electron apps in Visual Studio (i.e. not Visual Studio Code)?

Viewed 72

I would like to build and debug Electron apps in Visual Studio 2022. I can debug Electron apps in Visual Studio Code by following this guide. How do I go about debugging Electron apps in Visual Studio? Or is debugging Electron apps in Visual Studio not possible?

Visual Studio 2022 appears to not have a template for creating Electron projects. Is it still possible to import an existing Electron project and then debug the imported project?

1 Answers

After some experimentation I was eventually able to debug electron apps in Visual Studio. I should probably clarify that I'm debugging the main process, not the renderer process. I still need to use Visual Studio Code (VSCode) to debug the renderer process.

  1. I started with setting up debugging in VSCode as described on the electron pages.
  2. Then you need to create a Visual Studio solution and a Visual Studio project for the electron app. As long as the Visual Studio Project is in the same folder as the package.json for your electron app, all the relevant files should be visible in Visual Studio automatically. Make sure that the .vscode folder is not ignored by visual studio as the launch.json file is used for the debug configuration.
  3. In visual studio you need to select the Debug Main Process launch configuration (the configuration from step 1) and click launch
  4. You shold now be able to debug electron apps in Visual Studio.
Related