Khalil Khalaf
Khalil Khalaf

Reputation: 9407

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:

enter image description here

VS 2019:

enter image description here

Upvotes: 5

Views: 6070

Answers (6)

ChubbyMonkey
ChubbyMonkey

Reputation: 11

Had the same problem. The resolution was to open the .vcxproj.user file delete the true reload visual studio - problem solved.

Upvotes: 1

Nov4
Nov4

Reputation: 1

In my case the filter file was saved like .filters instead of .vcxproj.filters .

Probably due to manual files mangling something went wrong and VS2019 did not imported correctly this file anymore.

My solution was to create a new filter "test" and replacing the .filters content into the new file.

Upvotes: 0

Orit
Orit

Reputation: 343

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.

Upvotes: 1

Peter
Peter

Reputation: 767

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.

Upvotes: 1

Tushar R.
Tushar R.

Reputation: 318

  1. Delete .vs folder from project directory.
  2. Copy existing filter file to the project directory.
  3. Open the project. Now the filters should be available.

Upvotes: 9

Dmytro
Dmytro

Reputation: 138

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>

Upvotes: 2

Related Questions