Debug in VS Code
This guide will walk you through setting up VS Code for debugging the Core Process of your Tauri app.
All platforms with vscode-lldb extension
Prerequisites
Install the vscode-lldb
extension.
Configure launch.json
Create a .vscode/launch.json
file and paste the below JSON contents into it:
This uses cargo
directly to build the Rust application and load it in both development and production modes.
Note that it does not use the Tauri CLI, so exclusive CLI features are not executed. The beforeDevCommand
and beforeBuildCommand
scripts must be executed beforehand or configured as a task in the preLaunchTask
field. Below is an example .vscode/tasks.json
file that has two tasks, one for a beforeDevCommand
that spawns a development server and one for beforeBuildCommand
:
Now you can set breakpoints in src-tauri/src/main.rs
or any other Rust file and start debugging by pressing F5
.
With Visual Studio Windows Debugger on Windows
Visual Studio Windows Debugger is a Windows-only debugger that is generally faster than vscode-lldb
with better support for some Rust features such as enums.
Prerequisites
Install the C/C++ extension and follow https://code.visualstudio.com/docs/cpp/config-msvc#_prerequisites to install Visual Studio Windows Debugger.
Configure launch.json and tasks.json
Note that it does not use the Tauri CLI, so exclusive CLI features are not executed. The tasks.json
is the same as with lldb
, except you need to add a config group and target your preLaunchTask
from launch.json
to it if you want it to always compile before launching.
Here is an example of running a dev server (equivalent of beforeDevCommand
) and the compilation (cargo build
) as a group, to use it, change the preLaunchTask
config in launch.json
to dev
(or anything you named your group).
© 2024 Tauri Contributors. CC-BY / MIT