Multi-root Workspace Support
Work with multiple solutions and projects across different workspaces.
Overview
C# Dev Tools supports VS Code's multi-root workspace feature, allowing you to work with multiple solutions simultaneously.
What is a Multi-root Workspace?
A multi-root workspace allows you to open multiple folders in a single VS Code window:
- Each folder can contain its own solution
- Each solution is displayed separately in the Solution Explorer
- You can work across multiple solutions simultaneously
- Settings can be configured per workspace folder
Creating a Multi-root Workspace
Method 1: Add Folder to Workspace
- Open a folder with a solution
- Go to File > Add Folder to Workspace
- Select another folder containing a solution
- Both solutions will appear in the Solution Explorer
Method 2: Save Workspace File
- After adding folders, go to File > Save Workspace As
- Save the workspace file (.code-workspace)
- Open this file later to restore the multi-root workspace
Working with Multiple Solutions
Solution Selection
When multiple solutions are open:
- Each solution appears with its workspace folder name
- Use the dropdown in the Solution Explorer to switch between solutions
- Each solution maintains its own state and context
Building Across Solutions
You can build projects from different solutions:
- Right-click any project and select Build
- The build targets only the selected project
- Dependencies are resolved within each solution
Running Projects
When running or debugging:
- Set the startup project in the desired solution
- Press F5 or use the debug controls
- The correct project will launch
Workspace Configuration
Per-Solution Settings
You can configure settings per workspace folder:
- Open the workspace settings file (.code-workspace)
- Add folder-specific settings under
folders[].settings
- Each solution can have its own:
- Build configurations
- Test settings
- NuGet sources
Example Workspace File
{
"folders": [
{
"path": "project-frontend",
"name": "Frontend"
},
{
"path": "project-backend",
"name": "Backend"
}
],
"settings": {
"csharp-dev-tools.solutionViewer.autoLoad": true
}
}
Use Cases
Microservices Development
- Open multiple service solutions simultaneously
- Work on shared libraries and services together
- Test integration across services
Frontend and Backend
- Open frontend solution (e.g., Blazor)
- Open backend solution (e.g., Web API)
- Develop both simultaneously
Shared Libraries
- Open application solution
- Open shared library solution
- Modify and test library changes immediately
Benefits
Productivity
- Reduce context switching
- See related projects side-by-side
- Work on dependencies without switching windows
Testing
- Test integration between projects
- Run multiple applications simultaneously
- Debug across solution boundaries
Code Sharing
- Reference code across solutions
- Copy code between projects easily
- Maintain consistency across codebases
Limitations
Project References
Project references work best within a single solution. Cross-solution references may require:
- NuGet packages for stable dependencies
- Shared projects for code reuse
- Relative path references (less portable)
Build Order
Build dependencies are managed per solution:
- Projects in different solutions may need manual build ordering
- Use solution-level build configurations for complex scenarios
Best Practices
Organize Related Work
- Group related solutions in one workspace
- Use descriptive folder names
- Keep workspace files in source control
Manage Complexity
- Don't open too many solutions (2-4 is ideal)
- Close unused solutions to reduce clutter
- Use solution folders to organize projects within each solution
Performance Considerations
- Multiple large solutions may impact performance
- Close solutions not actively being used
- Adjust file watcher settings if needed
Troubleshooting
Solutions Not Loading
If solutions don't load in a multi-root workspace:
- Check that each folder contains a .sln file
- Refresh the Solution Explorer
- Verify folder paths in the workspace file
Context Confusion
If you're unsure which solution is active:
- Check the Solution Explorer title bar
- Use the solution dropdown to verify
- Note the workspace folder name next to each solution
Build Failures
If builds fail in multi-root workspaces:
- Ensure project references are within the same solution
- Check NuGet package restoration
- Build solutions independently to isolate issues