Debugging External Sources with Visual Studio
Have you ever needed to debug and step into a code of dependent NuGet or .NET libraries that do not build as part of your solution? Today, debugging through them is not so easy as debugging your projects that are part of your solution. Starting with Visual Studio 2022 Preview 3, we are adding a new “External Sources” node in the Solution Explorer which will make debugging external sources files much easier. This node appears while debugging and will show sources for managed modules with symbols loaded containing Source Link or Source Server information. You can effortlessly browse those sources files and debug through them by placing breakpoints if needed.
Visual Studio 2022 team is working to deliver the promise of personal and team productivity. Debugging external sources is a capability in diagnostics tools that is just one of the exciting features we are working on.
External Sources node in Solution Explorer
The feature adds a new top-level node to Solution Explorer, which appears when you are in a debugging session and any loaded symbol file (.pdb) with Source Server information will appear under this node.
In debug mode – collapsed state (default)
In debug mode – an expanded state with no modules with symbols outside of the solution loaded
In debug mode – with one external module loaded and expanded
You can browse for files by expanding the tree items. Then, double-click an item to download the file from Source Server and open it in the editor. The node will persist with the module sources across the debugging sessions if the modules are set to load symbols automatically.
Demo for External Sources
If you are working with applications with multiple external libraries which have their components published to Source Servers e.g. Newtonsoft.Json, CsvHelper, xUnit.net, etc. this feature will give you an easier way to browse those sources and debug through them if needed.
The Symbol loading and source downloading can be managed by options under debugging settings.
Follow the settings checklist below to make sure modules can appear in Solution Explorer’s “External Sources” node.
- In the Tools -> Options -> Debugging options
- Disable Just My Code: This will allow the debugger to attempt to locate symbols for code outside your solution.
- In the Tools -> Options > Debugging -> Symbols options
- Enable Microsoft Symbol Server: This allows the debugger to attempt to locate symbols on Microsoft Symbol Server
- Enable NuGet.org Symbol Server: This allows the debugger to attempt to locate symbols on NuGet.org Symbol Server
- Enable Load All Modules: This allows the debugger to load symbols for all modules. (Note these options will load all available symbols, you can restrict symbol loading by selecting “Load only specified modules” and specifying included modules.)
- You may also need to check Debug -> Windows -> Modules to see which modules are currently loaded into memory and manually load any if required.
- You may be prompted to download the source from the server once you double-click the item in the “External Sources Node; click “Accept” and you can view the source code for that item in the editor.
Demo for External Sources with manual symbol loading
Let us know what you think!
This is the first step towards creating a first-class external source debugging experience for Visual Studio. We will soon be bringing this change for native code as well. We really appreciate you taking the time to try our newest feature and we hope you will provide your honest feedback by taking this brief survey.