Solution Explorer
Running and Debugging
Build, run, and debug your .NET applications directly from the Solution Explorer.
Overview
Section titled “Overview”C# Dev Tools integrates with VS Code’s debugging and task system to provide a seamless development experience for .NET applications.
Building Projects
Section titled “Building Projects”Build Commands
Section titled “Build Commands”Right-click on a project or solution and select:
- Build: Compile the project and its dependencies
- Rebuild: Clean and then build the project
- Clean: Remove all build artifacts (bin/ and obj/)
Build Output
Section titled “Build Output”Build output appears in:
- The Terminal panel - Shows full build logs
- The Problems panel - Lists errors and warnings
- Status bar - Shows build progress
Keyboard Shortcuts
Section titled “Keyboard Shortcuts”Ctrl+Shift+B- Build the current project- Configure additional shortcuts in keyboard settings
Setting a Startup Project
Section titled “Setting a Startup Project”The startup project is the project that runs when you press F5:
Set Startup Project
Section titled “Set Startup Project”- Right-click on an executable project (console app, web app, etc.)
- Select Set as Startup Project
- The project name will appear in bold in the Solution Explorer
Multiple Startup Projects
Section titled “Multiple Startup Projects”To run multiple projects simultaneously:
- Configure launch.json for multiple configurations
- Or use VS Code’s compound launch configurations
- Useful for running client and server projects together
Running Applications
Section titled “Running Applications”Console Applications
Section titled “Console Applications”To run a console application:
- Set it as the startup project
- Press
F5to run with debugging - Or press
Ctrl+F5to run without debugging
The application will run in the integrated terminal.
Web Applications
Section titled “Web Applications”To run a web application (ASP.NET Core):
- Set it as the startup project
- Press
F5to launch with debugging - The application will start and the browser will open automatically
The browser will navigate to the configured URL (usually https://localhost:5001).
Stopping Applications
Section titled “Stopping Applications”To stop a running application:
- Click the Stop button in the debug toolbar
- Press
Shift+F5 - Close the terminal (for console apps)
Debugging
Section titled “Debugging”Starting a Debug Session
Section titled “Starting a Debug Session”- Set breakpoints by clicking in the left margin of the editor
- Set the startup project
- Press
F5to start debugging
The debugger will:
- Build the project if needed
- Launch the application
- Attach the debugger
- Stop at your breakpoints
Debug Features
Section titled “Debug Features”While debugging, you can:
- Step Through Code: F10 (Step Over), F11 (Step Into), Shift+F11 (Step Out)
- Inspect Variables: Hover over variables or use the Variables panel
- Watch Expressions: Add expressions to the Watch panel
- Call Stack: View the call stack in the Call Stack panel
- Breakpoints: Manage breakpoints in the Breakpoints panel
Inline Debug Values
Section titled “Inline Debug Values”C# Dev Tools provides inline debug values that show variable values directly in your code:
- Variable values appear at the end of lines during debugging
- Changed values are highlighted
- Arrays and objects show their contents inline
Configure this feature in the extension settings.
Conditional Breakpoints
Section titled “Conditional Breakpoints”Set breakpoints that only trigger under specific conditions:
- Right-click on a breakpoint
- Select Edit Breakpoint
- Choose a condition type:
- Expression is true
- Hit count
- Log message
Launch Configurations
Section titled “Launch Configurations”Viewing Launch Configuration
Section titled “Viewing Launch Configuration”The extension automatically generates launch configurations:
- Open
.vscode/launch.json - View the generated configurations
- Customize as needed
Program Arguments
Section titled “Program Arguments”To pass command-line arguments:
Method 1: Edit launch.json
{ "args": ["arg1", "arg2", "arg3"]}Method 2: Use Code Lens
Click the Code Lens above the Main method to configure arguments.
Environment Variables
Section titled “Environment Variables”Set environment variables in launch.json:
{ "env": { "ASPNETCORE_ENVIRONMENT": "Development", "MY_VAR": "value" }}Running Tests
Section titled “Running Tests”The Solution Explorer integrates with the Test Explorer:
- Right-click on a test project
- Select Run Tests
- Tests will execute and results will appear in the Test Explorer
See the Testing Integration section for more details.
Build Configurations
Section titled “Build Configurations”Debug vs Release
Section titled “Debug vs Release”Switch between build configurations:
- Open the command palette (
Ctrl+Shift+P) - Type “C# Solution Explorer: Select Build Configuration”
- Choose Debug or Release
Debug builds:
- Include debugging symbols
- Disable optimizations
- Enable assertions
Release builds:
- Exclude debugging symbols
- Enable optimizations
- Better performance
Custom Configurations
Section titled “Custom Configurations”Create custom build configurations in your project files:
<PropertyGroup Condition="'$(Configuration)'=='CustomConfig'"> <!-- Custom configuration properties --></PropertyGroup>Troubleshooting
Section titled “Troubleshooting”Build Fails
Section titled “Build Fails”If build fails:
- Check the Problems panel for errors
- Review the Terminal output for detailed messages
- Ensure all NuGet packages are restored
- Verify target framework is installed
Cannot Start Debugging
Section titled “Cannot Start Debugging”If debugging won’t start:
- Ensure the startup project is set
- Check that launch.json is configured correctly
- Verify the project builds successfully
- Check for port conflicts (web applications)
Breakpoints Not Hit
Section titled “Breakpoints Not Hit”If breakpoints aren’t working:
- Build in Debug configuration
- Ensure you’re debugging the correct process
- Check that the code file is part of the project
- Disable “Just My Code” if needed
Performance Issues
Section titled “Performance Issues”If builds or debugging is slow:
- Disable unnecessary extensions
- Exclude large folders from file watching
- Use Release configuration for non-debugging runs
- Close unused projects in the solution