visual-studio 如何告诉 Visual Studio 从“在文件中查找”中排除文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1607069/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I tell Visual Studio to exclude folders from the Find in Files?
提问by Bernard
We use subversion so we have subfolders named _svn in our solution. Doing a Find in Files returns strings from these subfolders. Is there anyway to tell Visual Studio to ignore these files?
我们使用 subversion,所以我们的解决方案中有名为 _svn 的子文件夹。在文件中查找会从这些子文件夹中返回字符串。有没有告诉 Visual Studio 忽略这些文件?
回答by rafbel
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.
您可以做的是设置一组将用于搜索的文件夹。在“查找和替换”窗口中,在“查找范围”输入的右侧,您有一个“选择搜索文件夹”选项,您可以在其中设置这些文件夹集。
如果您添加了根项目文件夹,请记住关闭“包括子文件夹”选项。
如果您没有数百个文件夹,则此解决方案应该有效。
回答by AardVark71
Never had an issue with the global find until we moved to Visual Studio 2017and started with Angular + .net Core applications... (mostly problems with the HUGE node_modules folder being searched)
在我们迁移到Visual Studio 2017并开始使用 Angular + .net Core 应用程序之前,全局查找从来没有问题......(主要是搜索巨大的 node_modules 文件夹的问题)
I found that using the MSBuild exclusion property DefaultItemExcludesis working fine to exclude from global find in Visual studio 2017..
我发现使用 MSBuild 排除属性DefaultItemExcludes可以很好地从 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):
我现在默认打开 VS2017 中新核心项目的项目文件 (.csproj) 并按如下方式调整属性以排除 node_modules(有时我也会添加 wwwroot):
<DefaultItemExcludes>$(DefaultItemExcludes);node_modules\**</DefaultItemExcludes>
<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 :
另请参阅 https://github.com/dotnet/cli/issues/7525,他们建议在文件夹之前添加要排除的文件夹,并且似乎使用正斜杠而不是反斜杠,如下所示:
<PropertyGroup>
<DefaultItemExcludes>node_modules/**;$(DefaultItemExcludes)</DefaultItemExcludes>
</PropertyGroup>
Hope this helps anyone experiencing issues with VS2017 global find / search .
希望这可以帮助任何遇到 VS2017 全局查找/搜索问题的人。
回答by brightfunction
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!
我在使用 Visual Studio 2015 和 TortoiseSVN 迁移到 Windows 10 时遇到了这个问题。以前 .svn 文件夹都是隐藏的,所以没有出现在搜索结果中。为了解决这个问题,我只需转到 Windows 资源管理器中的文件夹属性并检查 .svn 文件夹的“隐藏”属性。在 Visual Studio 中刷新文件夹视图后,.svn 文件夹不再出现并且在使用 Find 时被忽略!
回答by Xavier Nodet
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.
您可以将搜索限制为项目或解决方案的一部分,而不是在目录(在本例中为您的解决方案的目录)中搜索文件。_svn 目录中的那些将因此被忽略。
回答by Andy Braham
I found in Visual Studio 2017especially when using Angular Clithat 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.
我在Visual Studio 2017 中发现,尤其是在使用Angular Cli 时,有时会在不知不觉中将生成的 javascript 文件或其他构建文件添加到您的项目中。这可能会导致一些令人头疼的问题,包括向搜索添加一堆文件并真正减慢速度,尤其是智能感知,因为它正在搜索源文件之上的所有生成的文件。
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.
我发现纠正此问题的最简单方法是只需右键单击构建文件夹(即{Project}/dist)并选择Exclude from Project. 这将从项目中删除该文件夹,但生成的内容仍可用于运行时,它只是从 UI 中隐藏。
If you need to still see the files, you can show hidden directories and files by selecting Show all Filesor
click on the Icon:
on the top of the Solution Explorer.
如果您仍然需要查看文件,您可以通过选择Show all Files或单击
解决方案资源管理器顶部的图标: 来显示隐藏的目录和文件。
Basically you want to exclude all build folders from your project/solution.
基本上你想从你的项目/解决方案中排除所有构建文件夹。
回答by Luká? Lánsky
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).
我认为您不能设置它(毕竟,您要求的是“整个解决方案”搜索),但通常您可以从项目中删除文件夹/隐藏文件系统中的目录(对于网站项目类型)。

