Use wildcards to exclude directories from indexing
We have a C# solution with many projects, and each creates a Project/obj directory during the build process. Rider includes these directories in the solution and indexes them by default, so it will start indexing them during the build.
We have been able to turn off indexing for all of these directories by adding an entry for every project in the explicitExcludes XML element in the /.idea/.idea.Solution/.idea/indexLayout.xml file, in the form <Path>Project/obj</Path>.
This is awkward and will need to be kept in sync with the list of projects, but the obvious wildcard (i.e. <Path>*/obj</Path>) didn't seem to work. Is there some non-obvious wildcard syntax which works in this folder, or is it not possible?
Please sign in to leave a comment.
Hello,
If it suits your use-case, you can exclude certain file type from indexing by mask using Settings | Editor | File Types | Ignored Files and Folders (please, see also the online help description).
If you need to exclude subfolders, please consider using a Directory.Build.props file at the root of the solution directory to exclude the obj subfolders from the project model, e.g.
Hi,
Thanks for your reply.
The “Ignored Files and Folders” also doesn't appear to support wildcards, so that won't work for our issue.
I tried adding the suggested <ItemGroup> to our shared props file, but it doesn't stop the directories being indexed; they're not initially shown in the Solution Explorer, but when I turn on “Show All Files”, it doesn't show “ - no index” next to the /obj/ directories. With our current approach (individually excluding each /obj/ directory in indexLayout.xml), it does show “ - no index” next to the /obj/ directories.
Hello Simon,
The solution you are currently using is the best one you can get in Rider for excluding folders from being indexed. Unfortunately, it doesn't support wildcards.
You mentioned that Rider indexes all the <project>/obj directories. Would you mind elaborating on this? It shouldn't index everything there. Would you mind checking if you see a similar picture in a newly created project?
As you can see, only a few files from the obj directory are indexed.
If you notice the indexing behavior is different between a newly created project and your one, would you mind elaborating on what exact files are being indexed in your case?
Are the files from obj directory included in .csproj somehow?
Have a nice day!
Sorry for the delay in replying.
The behaviour is the same for a newly-created project as in your screenshot - only a few files are indexed, mostly .g.cs files. However, those are the files we would like to automatically exclude - due to our solution structure, we have quite a few *.g.cs and *.g.i.cs files in our Project/obj/ directories.
Hello Simon,
Thank you for the update.
Unfortunately, I have no other solution to suggest. You already exclude files from being indexed through the
/.idea/.idea.Solution/.idea/indexLayout.xml. Unfortunately, it doesn't support wildcards.Apologies for the inconvenience. Feel free to submit a feature request to our tracker.
Have a nice day!