开发者

How can I tell Visual Studio to exclude folders from the Find in Files?

开发者 https://www.devze.com 2022-12-09 07:57 出处:网络
We use subversion so we h开发者_Python百科ave subfolders named _svn in our solution. Doing a Find in Files returns strings from these subfolders.

We use subversion so we h开发者_Python百科ave subfolders named _svn in our solution. Doing a Find in Files returns strings from these subfolders. Is there any way to tell Visual Studio to ignore these files?


From "Find in Files", in "File Types" or "Look at these file types", you can use:

!*\ExcludeFolder\*

Example:

!*\bin\*;!*\obj\*;!*\.*;!*\ExcludeFolder\*

How can I tell Visual Studio to exclude folders from the Find in Files?


What you can do is to setup a set of folders that will be used for searching. In Find and Replace window, on the right hand side of "Look In" input you have a "Choose Search Folders" option where you can setup those sets of folders.
Just remember to turn off "Include sub folders" options if you have added root project folder.
If you don't have hundreds of folders this solution should work.


Never had an issue with the global find until we moved to Visual Studio 2017 and started with Angular + .net Core applications... (mostly problems with the HUGE node_modules folder being searched)

I found that using the MSBuild exclusion property DefaultItemExcludes is working fine to exclude from global find in Visual studio 2017..

I now by default open up the project file (.csproj) for a new core project in VS2017 and adjust the property as follows to exclude the node_modules (sometimes I add the wwwroot too):

<DefaultItemExcludes>$(DefaultItemExcludes);node_modules\**</DefaultItemExcludes>

See also https://github.com/dotnet/cli/issues/7525 , there they advise to prepend the folders to exclude and seem to use a forward slash instead of backward slash, like this :

<PropertyGroup>
  <DefaultItemExcludes>node_modules/**;$(DefaultItemExcludes)</DefaultItemExcludes>
</PropertyGroup>

Hope this helps anyone experiencing issues with VS2017 global find / search .


I had this problem when moving to Windows 10 using Visual Studio 2015 and TortoiseSVN. Previously the .svn folders were all hidden so did not appear in search results. To solve this I simply went to the folder properties in Windows Explorer and checked the 'Hidden' attribute for the .svn folder. After refreshing the folder view in Visual Studio the .svn folder no longer appeared and is ignored when using Find!

How can I tell Visual Studio to exclude folders from the Find in Files?


Instead of searching for files in a directory (your solution's directory, in this case), you could limit your search to the files that are part of the project or the solution. Those in the _svn directories will thus be ignored.


I found in Visual Studio 2017 especially when using Angular Cli that the generated javascript files or other build files can be added to your project sometimes unknowingly. This can cause several headaches including adding a bunch of files to the searches and really slowing things down, especially intellisense because it is searching all of the generated files on top of the source files.

The easiest way I have found to correct this is to simply right click on the build folder (i.e. {Project}/dist) and select Exclude from Project. This will remove the folder from the project but the generated contents will still be available for runtime, it is just hidden from the UI.

How can I tell Visual Studio to exclude folders from the Find in Files?

If you need to still see the files, you can show hidden directories and files by selecting Show all Files or click on the Icon:

How can I tell Visual Studio to exclude folders from the Find in Files?

on the top of the Solution Explorer.

Basically you want to exclude all build folders from your project/solution.


I don't think you can set this (after all, you are asking for "Entire Solution" search), but often you can remove the folder from the project / hide the directory in filesystem (for Web Site project type).


If you are not using VS2019 or VS Code (for which the solution has already been found in other answers), as a workaround you can use the search in Far Manager, it supports masks to exclude certain files or folders from the search.

How can I tell Visual Studio to exclude folders from the Find in Files?

0

精彩评论

暂无评论...
验证码 换一张
取 消