'Why filters are no longer working after migrating to Visual Studio 2019?
After migrating from VS 2015 to VS 2019, filters for Solution Explorer do not work anymore. Why?
In VS 2015, and in order to categorize files in the Solution Explorer without creating physical folders, I have .filters file for each project. Filters show same-type files in a sorted order in the Solution Explorer (on a per-folder basis: Headers, Source, Debug ... etc). Right now, it is not working. And if I do Add->Existing for each project, and choose the respective filter for the selected project, I see no difference (even after unloading/loading, closing/opening VS.. etc)
I went through the filters file and made sure that nothing is wrong with them and all project's file are actually list. Any one can help?
VS 2015:
VS 2019:
Solution 1:[1]
- Delete .vs folder from project directory.
- Copy existing filter file to the project directory.
- Open the project. Now the filters should be available.
Solution 2:[2]
I had the problem like this and was playing with .filters file to understand what's srong. So after some time I've found that file include tags should be sorted according to folders! So for examle, if you have such a structure:
/folder
/sub1
/sub2
Your file should look like:
<ClInclude Include="folder1\file1.h">
<Filter>folder</Filter>
</ClInclude>
<ClInclude Include="folder1\sub1\file2.h">
<Filter>folder\sub1</Filter>
</ClInclude>
<ClInclude Include="folder1\sub2\file3.h">
<Filter>folder\sub2</Filter>
</ClInclude>
In my case the sorting was not correct and in Visual Studio IDE I was getting flat list of project files. I had something like this:
<ClInclude Include="folder1\sub1\file2.h">
<Filter>folder\sub1</Filter>
</ClInclude>
<ClInclude Include="folder1\sub2\file3.h">
<Filter>folder\sub2</Filter>
</ClInclude>
<!-- This subfolder was not at the place -->
<ClInclude Include="folder1\file1.h">
<Filter>folder</Filter>
</ClInclude>
Solution 3:[3]
My .filters file had an error in it that was introduced during a merge. I compared the before and after and spotted a tag that no longer had a closing tag. After I add the closing tag I was able to open the project and my filters returned.
So if there's an error in the xml structure the filters stop working.
Solution 4:[4]
Had the same problem, try adding a new filter and move some files to that new filter. Close the VS while saving the ".filter" file, and re-open the VS, it retrieves the old filters. Now you can sort back your files.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tushar R. |
| Solution 2 | Dmytro |
| Solution 3 | Peter |
| Solution 4 | Orit |


