Visual Studio Debugging Setup
Basic Debugging
- Open
PowerToys.slnxin Visual Studio - Set
runneras the startup project:- Right-click the
runnerproject in Solution Explorer - Select Set as Startup Project
- Right-click the
- Select your build configuration (Debug/Release)
- Start debugging:
- Press
F5, or - Click Local Windows Debugger, or
- Menu: Debug > Start Debugging
- Press
Elevated Debugging
Some PowerToys modules require elevated (administrator) privileges to function properly:- FancyZones: Cannot move elevated windows to zones without elevation
- Shortcut Guide: Won’t appear when elevated applications are in foreground
Debugging Child Processes
Many PowerToys modules run as separate processes launched by the runner. To debug these:Using Debug Child Processes Extension
- Install the extension:
-
Configure child process debugging:
- Tools > Options > Child Process Debugging Settings
- Add process names to debug automatically
- Specify debugger type (.NET, Native, or Mixed)
-
Start debugging:
- Start PowerToys from Visual Studio
- Extension automatically attaches to child processes
Manual Attach
Alternatively, attach manually to running processes:- Start PowerToys (with or without debugger)
- Press
Ctrl+Alt+Pin Visual Studio - Search for your module’s process name
- Select and attach
PowerToys.AdvancedPaste.exeColorPickerUI.exePowerToys.Awake.exePowerToys.FancyZones.Editor.exePowerToys.PowerLauncher.exe
Debugging Specific Components
Module Interface DLLs
Module interface DLLs load directly into the runner process:- Set breakpoints in the DLL code
- Start debugging the runner
- Breakpoints will hit automatically when the module loads
Settings UI
To debug the Settings application:- Start PowerToys with debugging
- Open Settings from the system tray
- Attach to
PowerToys.Settings.exeprocess - Or use child process debugging extension
Color Picker Example
Debug both native and managed code together:- Set breakpoints in:
- ColorPicker module interface (native C++)
- ColorPickerUI (C# WinUI)
- Configure child process debugging for
ColorPickerUI.exe - Start runner with debugger
- Activate Color Picker with its hotkey
- Both breakpoints will hit appropriately
Short-Lived Processes
For processes that start and exit quickly (like Workspaces apps):- List all process names explicitly in child process debugging
- Set correct debugger type (.NET for C# processes)
- Set breakpoints early in the process lifecycle
- Consider adding debug delays in code during development:
Debugging with Logs
Log Locations
Runner and module logs:C++ Logging
PowerToys uses spdlog for C++ logging:C# Logging
C# projects use theLogger class from ManagedCommon:
Finding Issues in Logs
Search for common error patterns:Debugging Tools
Windows Event Viewer
For application crashes:- Open Event Viewer:
eventvwr.msc - Navigate to: Windows Logs > Application
- Filter for:
- Source: Application Error
- Search for: PowerToys, module names
- Export crash XML for analysis
WinObj Tool
For finding registered events and synchronization objects:- Download WinObj from Sysinternals
- Run as administrator
- Search for event names used by modules
- Shows handles to events (typically runner and module)
Process Monitor
For file, registry, and process activity:- Download Process Monitor
- Filter for PowerToys processes
- Monitor:
- File operations
- Registry access
- Process creation
Visual Studio Diagnostic Tools
While debugging:-
Diagnostic Tools window (Ctrl+Alt+F2):
- Memory usage
- CPU usage
- Events timeline
-
Performance Profiler (Alt+F2):
- CPU Profiling
- Memory Profiling
- Database queries
-
Live Visual Tree (Ctrl+Q, search “Live Visual Tree”):
- Inspect WinUI/UWP UI hierarchy
- View property values
- Debug layout issues
Debugging Scenarios
Bug Report Analysis
When working with user bug reports:- Check module-specific logs for exceptions or crashes
- Copy user’s settings from Bug Report to your machine:
- Review Event Viewer XML files for crash details
- Compare installation structure with
installation_folder_structure.txt - Check installer logs for installation issues:
- Note Windows version and language for environmental patterns
Installer Debugging
The installer can only be built in Release mode: Debug techniques:- Add logging statements
- Use message boxes for critical paths
- Check installer logs:
- Missing dependencies
- File conflicts
- Registry access issues
- Elevation problems
DPI and Multi-Monitor Issues
For testing DPI-related problems:- Use at least 2 monitors with different DPI settings
- Test with:
- 100% (96 DPI)
- 125% (120 DPI)
- 150% (144 DPI)
- 200% (192 DPI)
- Test monitor arrangement changes
- Test disconnect/reconnect scenarios
Wake/Resume Issues
Background modules often fail after sleep/wake:-
Add logging around:
- Event handle recreation
- Service restart logic
- Resource reinitialization
-
Test scenarios:
- Sleep/wake cycle
- Hibernate/resume
- Monitor disconnect/reconnect
- Lock/unlock
Performance Issues
For performance debugging:Build Error Troubleshooting
Corrupted Build State
Symptoms: Missing files, asset errors, unexpected build failures Solution:NuGet Package Issues
Symptoms: Package restore failures, missing references Solution:Submodule Issues
Symptoms: Missing dependencies fromdeps\ folder
Solution:
Testing in Isolated Environments
Windows Sandbox
Test clean installations:- Enable Windows Sandbox
- Copy installer to host folder shared with sandbox
- Install and test in clean environment
Fresh User Profile
Simulate new user experience:Multiple Computers
Some features require multiple physical machines:- Mouse Without Borders: Requires 2+ physical computers (not VMs)
- Multi-monitor utilities: Test with various monitor configurations
Debugging Checklist
Before reporting or fixing a bug:- Reproduced the issue consistently
- Checked logs for errors or exceptions
- Verified build is up-to-date
- Tested in both elevated and non-elevated modes
- Checked Event Viewer for crashes
- Tested with clean user settings
- Documented steps to reproduce
- Identified which module is affected
- Verified system meets requirements
Next Steps
Building
Learn how to build PowerToys from source
Testing
Write and run tests for your changes
Coding Style
Follow PowerToys coding conventions
Creating New Utility
Step-by-step guide to build a new utility