-
-
Notifications
You must be signed in to change notification settings - Fork 736
Debugging
ElectronNET.Core transforms the debugging experience by providing native Visual Studio integration with multiple debugging modes. No more complex setup or manual process attachment—debugging now works as expected for .NET developers.
ElectronNET.Core supports three main debugging approaches, all configured through Visual Studio's launch profiles:
Debug your .NET code directly with full Hot Reload support:
{
"profiles": {
"ASP.Net (unpackaged)": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:8001/"
}
}
}Benefits:
- ✅ Full C# debugging with breakpoints
- ✅ Hot Reload for ASP.NET code
- ✅ Edit-and-continue functionality
- ✅ Native Visual Studio debugging experience
Debug the Electron process when you need to inspect native Electron APIs:
{
"profiles": {
"Electron (unpackaged)": {
"commandName": "Executable",
"executablePath": "node",
"commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron",
"workingDirectory": "$(TargetDir).electron",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}Benefits:
- ✅ Debug Electron main process
- ✅ Inspect native Electron APIs
- ✅ Node.js debugging capabilities
Debug Linux builds directly from Windows Visual Studio:
{
"profiles": {
"WSL": {
"commandName": "WSL2",
"launchUrl": "http://localhost:8001/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:8001/"
},
"distributionName": ""
}
}
}Benefits:
- ✅ Debug Linux applications from Windows
- ✅ Test Linux-specific behavior
- ✅ Validate cross-platform compatibility
Add the debugging profiles to Properties/launchSettings.json:
{
"profiles": {
"ASP.Net (unpackaged)": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:8001/"
},
"Electron (unpackaged)": {
"commandName": "Executable",
"executablePath": "node",
"commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron",
"workingDirectory": "$(TargetDir).electron",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WSL": {
"commandName": "WSL2",
"launchUrl": "http://localhost:8001/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:8001/"
},
"distributionName": ""
}
}
}When switching between Windows and WSL debugging:
- Right-click your project in Solution Explorer
- Select Properties
- Adjust the Runtime Identifier
Without Visual Studio:
- Edit the .csproj file
- Update the RuntimeIdentifier:
<!-- For Windows debugging -->
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<!-- For WSL/Linux debugging -->
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>For WSL debugging, ensure:
- WSL2 is installed and configured
- Linux distribution is set in the launch profile
- Project targets Linux RID for WSL debugging
- Select "ASP.Net (unpackaged)" profile in Visual Studio
- Press F5 to start debugging
- Set breakpoints in your C# code
- Use Hot Reload to edit ASP.NET code during runtime
- Stop debugging when finished
- Select "Electron (unpackaged)" profile
- Press F5 to start debugging
- Attach to Electron process if needed
- Debug Node.js and Electron APIs
-
Set RuntimeIdentifier to
linux-x64 - Select "WSL" profile
- Press F5 to debug in WSL
- Test Linux-specific behavior
- Works with ASP.NET-first debugging
- Edit Razor views, controllers, and pages
- See changes instantly without restart
- Preserves application state
// Set breakpoints here
public async Task<IActionResult> Index()
{
var data = await GetData(); // ← Breakpoint
return View(data);
}- ASP.NET-first mode automatically manages Electron process lifecycle
- Proper cleanup on debugging session end
- No manual process killing required
"Electron process not found"
- Ensure Node.js 22.x is installed
- Check that packages are restored (
dotnet restore) - Verify RuntimeIdentifier matches your target platform
"WSL debugging fails"
- Install and configure WSL2
- Ensure Linux distribution is properly set up
- Check that project targets correct RID
"Hot Reload not working"
- Use ASP.NET-first debugging profile
- Ensure ASPNETCORE_ENVIRONMENT=Development
- Check for compilation errors
Placeholder for image showing Visual Studio debugging interface with Electron.NET
The debugging interface provides familiar Visual Studio tools:
- Locals and Watch windows for variable inspection
- Call Stack for method call tracing
- Immediate Window for runtime evaluation
- Hot Reload indicator for edit-and-continue
- Startup Methods - Understanding different launch scenarios
- Package Building - Debug packaged applications
- Migration Guide - Moving from old debugging workflows
✅ Native Visual Studio Experience - No complex setup or manual attachment
✅ Hot Reload Support - Edit ASP.NET code during debugging
✅ Cross-Platform Debugging - Debug Linux apps from Windows
✅ Multiple Debugging Modes - Choose the right approach for your needs
✅ Process Lifecycle Management - Automatic cleanup and proper termination
Want to contribute to this documentation? Please fork and create a PR! The Wiki is autogenerated from the /docs content in the repository.