# Debug extension installation and upgrade
Use an attach debugging session to test and troubleshoot install and upgrade codeunits when an extension is installed or upgraded.
## Attach and debug
1. In Visual Studio Code, configure launch.json with request set to attach. Make sure that useSystemSessionForDeployment is false, which is the default. When it's true, install and upgrade codeunits run in a system session and can't be debugged.
1. Add breakpoints to the install or upgrade code that you want to debug.
1. Press F5 to start the attach debugging session.
1. After the debugger attaches, press Ctrl+F5 to run Publish extension without building.
If you don't increment the app version, the install codeunits run. If you increment the app version or set forceUpgrade to true in launch.json, the upgrade codeunits run.
Learn more about attach configurations in devenv-attach-debug-next. Learn more about setting breakpoints in Debugging in AL<devenv-debugging>.
## Related information
devenv-debugging
devenv-snapshot-debugging
devenv-attach-debug-next

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-debug-upgrade-install-code, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-debug-upgrade-install-code/
