This document covers techniques and tools for debugging PowerToys.
Before you can start debugging PowerToys, you need to set up your development environment:
- Fork the repository and clone it to your machine
- Navigate to the repository root directory
- Run
git submodule update --init --recursiveto initialize all submodules - Change directory to
.configand runwinget configure .\configuration.vsEnterprise.winget(pick the configuration file that matches your Visual Studio distribution)
You can build the entire solution from the command line, which is sometimes faster than building within Visual Studio:
- Open
Developer Command Prompt for VS - Navigate to the repository root directory
- Run the following command(don't forget to set the correct platform):
msbuild -restore -p:RestorePackagesConfig=true -p:Platform=ARM64 -m PowerToys.slnx /tl /p:NuGetInteractive="true"
- This process should complete in approximately 13-14 minutes for a full build
To debug the PowerToys application in Visual Studio, set the runner project as your start-up project, then start the debugger.
Some PowerToys modules must be run with the highest permission level if the current user is a member of the Administrators group. The highest permission level is required to be able to perform some actions when an elevated application (e.g. Task Manager) is in the foreground or is the target of an action. Without elevated privileges some PowerToys modules will still work but with some limitations:
- The
FancyZonesmodule will not be able to move an elevated window to a zone. - The
Shortcut Guidemodule will not appear if the foreground window belongs to an elevated application.
Therefore, it is recommended to run Visual Studio with elevated privileges when debugging these scenarios. If you want to avoid running Visual Studio with elevated privileges and don't mind the limitations described above, you can do the following: open the runner project properties and navigate to the Linker -> Manifest File settings, edit the UAC Execution Level property and change it from highestAvailable (level='highestAvailable') to `asInvoker (/level='asInvoker').
The Shell Process Debugging Tool is a Visual Studio extension that helps debug multiple processes, which is especially useful for PowerToys modules started by the runner.
- Install "Debug Child Processes" Visual Studio extension
- Configure which processes to debug and what debugger to use for each
- Start PowerToys from Visual Studio
- The extension will automatically attach to specified child processes when launched
- Set breakpoints in both ColorPicker and its module interface
- Use Shell Process Debugging to attach to ColorPickerUI.exe
- Debug .NET and native code together
- Runner needs to be running to properly test activation
- Breakpoints in DLL code will be hit when loaded by runner
- No special setup needed as DLL is loaded into runner process
- For processes with short lifetimes (like in Workspaces)
- List all processes explicitly in debugging configuration
- Set correct debugger type (.NET debugger for C# code)
- Run WinObj tool from SysInternals as administrator
- Search for event name
- Shows handles to the event (typically runner and module)
- Check module-specific logs for exceptions/crashes
- Copy user's settings to your AppData to reproduce their configuration
- Check Event Viewer XML files if logs don't show crashes
- Compare installation_folder_structure.txt to detect corrupted installations
- Check installer logs for installation-related issues
- Look at Windows version and language settings for patterns across users
- Can only build installer in Release mode
- Typically debug using logs and message boxes
- Logs located in:
%LOCALAPPDATA%\Temp\PowerToys_bootstrapper_*.log- MSI tool logs%LOCALAPPDATA%\Temp\PowerToys_*.log- Custom installer logs
- Logs in Bug Reports are useful for troubleshooting installation issues
- Use shell process debugging to connect to newly created processes
- Debug the
PowerToys.Settings.exeprocess - Add breakpoints as needed for troubleshooting
- Logs are stored in the local app directory:
%LOCALAPPDATA%\Microsoft\PowerToys - Check Event Viewer for application crashes related to
PowerToys.Settings.exe - Crash dumps can be obtained from Event Viewer
If you encounter build errors about missing image files (e.g., .png, .ico, or other assets), this typically indicates a corrupted build state. To resolve:
-
Clean the solution in Visual Studio: Build > Clean Solution
Or from the command line (
Developer Command Prompt for VS):msbuild PowerToys.slnx /t:Clean /p:Platform=x64 /p:Configuration=Debug
-
Delete build output and package folders from the repository root:
x64/ARM64/Debug/Release/packages/
-
Rebuild the solution
A PowerShell script is available to automate this cleanup:
.\tools\build\clean-artifacts.ps1This script will run MSBuild Clean and remove the build folders listed above. Use -SkipMSBuildClean if you only want to delete the folders without running MSBuild Clean.
After cleaning, rebuild with:
msbuild -restore -p:RestorePackagesConfig=true -p:Platform=x64 -m PowerToys.slnx