doc/devdocs/development/debugging.md
This document covers techniques and tools for debugging PowerToys.
Before you can start debugging PowerToys, you need to set up your development environment:
git submodule update --init --recursive to initialize all submodules.config and run winget 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:
Developer Command Prompt for VSmsbuild -restore -p:RestorePackagesConfig=true -p:Platform=ARM64 -m PowerToys.slnx /tl /p:NuGetInteractive="true"
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:
FancyZones module will not be able to move an elevated window to a zone.Shortcut Guide module 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.
%LOCALAPPDATA%\Temp\PowerToys_bootstrapper_*.log - MSI tool logs%LOCALAPPDATA%\Temp\PowerToys_*.log - Custom installer logsPowerToys.Settings.exe process%LOCALAPPDATA%\Microsoft\PowerToysPowerToys.Settings.exeIf 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.ps1
This 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