Load Only the Projects You Need with Solution Filters
You, like many other developers, may work in very large codebases that contain hundreds or thousands of projects in a single Visual Studio solution. However, you may only work with a few of those projects and their dependencies. Our Visual Studio team has seen multiple approaches that developers use to only load and work in the projects that they need. Solution Filters are a new, recommended approach that provide a focused and more performant workspace for you.
What are Solution Filters?
Solution Filters in Visual Studio allow you to selectively load and work with the projects that you need. For instance, if you work in a repository with hundreds of projects, you may only need a fraction of them. Solution Filters will simplify your work, with a clear distinction between which projects are loaded and unloaded. Anytime you open or close the solution, Visual Studio will remember and load the projects that were loaded in the previous session. You have an option to save subsets of projects as a Solution Filter file, ending in .slnf. This .slnf file refers to your main solution file, so it opens the entire solution but only loads the projects present in the .slnf file. You can choose to save this file locally, share it with other developers in your team, or share it across new instances of Visual Studio on separate machines.
Case Studies | Organizations using Solution Filters
Microsoft’s Edge
Microsoft’s web browser Edge is built on the top of the Chromium OS repository and contains thousands of projects. In the past, many of Microsoft’s Edge developers opened at least 10,000 projects daily, and some even had multiple instances of Visual Studio running. Many of these Edge developers preferred to work with a smaller subset of projects. Working together, the Visual Studio and Edge teams integrated Solution Filters into their developer workflows.
Edge developer, Luis, went from opening 10,080 projects each day to opening less than 150 projects per day. After he started using Solution Filters, his entire experience improved as he only loaded the projects and dependencies relevant to his work! Similarly, Edge developer Cliff, now works in a Solution Filter with 6-10 projects and said that “Solution Filters have vastly improved [his] Visual Studio experience.”
Enterprise Company
A large enterprise customer reported that they have 20 different sub-teams that each work with their own area of code, within the larger solution. As a workaround, they used to create 20 separate solutions for 20 different sub-teams. These solutions needed to be regenerated regularly and developers needed to load multiple solutions if they were collaborating across teams.
Instead, this company created 20 separate Solution Filters (one per team) that are nested in the larger solution. Each of their developers can have their own focused workspace, access shared pieces of code, and still switch to the entire solution when needed. This company feels that Solution Filters are “…all of our hopes and dreams… No other feature in VS 2019 is more important than this.”
Microsoft’s Azure Compute
Microsoft team, Azure Compute, has a massive repository, and their developers do not need to load all the code outside of their team workstreams. To maximize productivity, the Visual Studio team enabled Solution Filters by default for their solutions. This means that every time a developer opens Azure Compute for the first time, zero projects are loaded. When selecting projects to load for the first time, they can right click to load either the direct dependencies or the entire dependency tree for any project. After the initial opening, Visual Studio remembers all the projects that the developer loaded and loads this subset of projects in subsequent Visual Studio openings. The Azure Compute team found setting Solution Filters as the default opening workflow to be incredibly helpful and are now looking at expanding this workflow!
How do you create your own Solution Filters?
Getting started with Solution Filters is fast and simple! You only need to create your Solution Filter once, and then you can work in it anytime, and easily edit its contents when needed. The Solution Filter file can be shared with other developers, but does not necessarily need to be committed to source control.
- Select Open a project or solution on the start page.
- In the file open dialog select the desired solution. Before opening, click the Do not load projects checkbox in the bottom of “Open Project/Solution” dialog. (Or use the command /donotloadprojects if you open your solution from the command line.)
- After clicking the checkbox, select Open and your solution will load in Visual Studio with 0 / x projects loaded.
- Choose the projects you want to load by right clicking and selecting Reload Project or load the project and its entire dependency tree by clicking Reload Project with Dependencies.
- Optional: For any loaded project, right click to load the entire dependency tree or the direct dependencies.
- Optional: Choose to hide or show unloaded projects.
- Optional: Save as Solution Filter (.slnf) so that you can save this subset of projects and access it in the future. This .slnf file is saved in the solution folder and will show up in your Recents menu.
Additional Solution Filter Use Cases
Here are a few use cases in which users have leveraged Solution Filters for their personal and team needs.
As an individual developer, you can customize Solution Filters by loading the projects you use the most. For this scenario, your team can add the .slnf file type to the git ignore file to ensure that team members do not accidentally check in a bunch of them.
If your team works with a large solution, you may also have hundreds of test projects. For the bulk of work, these test projects may be unnecessary. You can create a Solution Filter that excludes the unit tests. When you need the tests, you can easily switch between the Solution Filter and the entire solution.
When a new team member joins, trying to understand hundreds of projects may be overwhelming, especially when only a few are needed to get started. Thus, you can create simple Solution Filters to allow your new team members to get up to speed in their designated area, before scaling up to the entire repository.
If your solution contains massive DLLs, it can be beneficial to remove those that aren’t used on a regular basis and to save these in a Solution Filter. You can easily switch back to the full solution if those DLLs are required for a specific task.
Your team may already have separate solution files or folders (or even an internally built version of Solution Filters) with the backend and frontend parts of the code. If you only work in one of these areas, create a Solution Filter that only includes that portion of the code, and share this with your team.
If your solution contains multiple pieces of client-specific code that relies on shared code, we have heard of teams creating separate solutions for each client. Instead, you can create a Solution Filter for each client’s code. In this scenario, you do not have to load any clients code except the one you’re working on but can still rely on all the shared projects that may be necessary to compile.
Solution Filters is a key part of the ongoing process of improving the experience for developers working in large solutions. Do you have any more use cases not mentioned? We want to hear how you’re using Solution Filters! Please email vssolutionload@microsoft.com with any feedback about Solution Filters. To learn more about Solution Filters and how they might improve your Visual Studio experience, click here.
6 comments
We’ve been using solution filters for the past couple of months, but there are still a lot of little bugs that need to be worked out. Hope they get worked out soon, because solution filters are pretty awesome! 🙂
I actually wrote a blog about this last month. I found it very useful aside from the fact that it does not work with glob patterns.
If you have any feedback on my article please let me know 🙂
This is SUCH a powerful feature that really needs usability focus and love. Why are you requiring the user to use a cumbersome “right-click solution” to create a new filter? This is neither discoverable nor appealing.
It should rather be a dialog whereby you check the projects in the filter you want, and create a new one from there. It should have it’s own File->Open->etc menu and everything. There should be a slick dropdown of all the filters to quickly load a different filter and assume a different role/area of the solution. I could go on and on here. 😛
Please put more resources behind this feature and flesh it out with some magic. ✨ 🙏
Solution filter still can’t work correctly today. I can’t even add slnf to MRU deterministically.
Sometimes when I double click a slnf, it brings the corresponding sln into MRU. Cleaning sln from MRU has no effect.
Maybe I am getting jaded…
I read this and my only take away was “great… one more thing to maintain/debug/support”.
Wouldn’t it have been easier to just let us add solutions to our master solutions? That seems like it would be easier to manage than having every developer use a different subset of projects.
I was looking for VSCode / OmniSharp support, and found,
MSBuild command line support and
OmniSharp Project Selector