Is there a way to exclude a particular type of .cs file when doing a search in Visual Studio 2005/8?
Example: In a refactoring scenario i might search to identify string literals in my code so that i can refactor them into constants or some such. However, *designer.cs files are full of string literals which i don't care to deal with but they show up in my search and pollute the result set.
i usually search for *.cs...
How do i ignore *.designer.cs?
Just search files types: *.aspx.vb
I see it's pretty late, but looking at the number of votes and activity on this page, I'm posting my answer; maybe someone else finds it useful. Here's how you can do this in VS2010 and above:
Enter the following command at PowerShell Prompt:
dir -Recurse | Select-String -pattern "Your Search Word Or Pattern" -exclude "*.designer.cs"
Additional Notes
"*.designer.cs"
with@("*.designer.cs", "*.designer.vb", "reference.cs")
or whatever other files you want to skip.One downside of this solution is that it doesn't let you double-click a line in the result to open that file in Visual Studio. You can workaround this limitation through command-piping:
dir -Recurse | Select-String -pattern "Your String Or Pattern" -exclude "*.designer.vb" | sort | Select -ExpandProperty "Path" | get-unique | ForEach-Object { $DTE.ExecuteCommand("File.OpenFile", """$_""") }
This will open all the files where the string or pattern was found in Visual Studio. You can then use Find window in individual files to locate the exact instances.
Another advantage of this solution is that it works in Express versions as well, since Package Manager is included in 2012 and 2013 Express versions; not sure about 2010 though.
The Microsoft Connect ticket "Find option to exclude designer generated code" indicates that filtering search by file extension won't be present in VS 2010.
It really blows for an answer but here's what I did after trying 'Exclude from project' only to find that these files were also searched.
All the files I didn't want included were, fortunately, in a folder off the root called 'Archived' so ... I cut and pasted the file to my desktop.
Maybe that's why Ultra Find Extension disappeared ... developers can group all unwanted files into a a folder off the web root and just remove it while they do searches, LOL.
A commercial option is the $29 Entrian Source Search add-in that can specify exclusion patterns
I just came across this question in my search for an answer to this very problem.
Got frustrated with VS and fell back on my trusty copy of UltraEdit and specified these options in its "Find in Files" tool: