Reputation: 7877
How to find text including .sln and .csproj? I wanted to search package version present in all the project. I have instance where package version is not captured in npm but is present in .csproj file and hence causes issues.
Upvotes: 19
Views: 8724
Reputation: 21476
For me, switching Solutions and Folders
view and doing the global search .csproj
file types did the trick!
Searching among .csproj
files only works when you're on Folder View.
Upvotes: 4
Reputation: 19330
Visual Studio has option called "Find in Files". You open the form, type your text you want to search for and you can actually set the file types. As example, if you want to search project files, solution files and code files, you can set filter as
*.??proj;*.sln;*.vb;*.cs;*.asax;*.ashx
We have mixture of c# and vb, so *.??proj
covers all of them.
Click "Find All"
When your search is over, in the result window, click on the line and it will take you to the line in file where your match is found
Important Note
When field "Look in" is set to "Entire Solution" or "Current Project" or "All open documents" search will totally skip
*.??proj
files even if they are listed in filter. If you unload the project and open project file for edit, "Entire Solution" and "All open documents" options will search through opened project file.
Also keep in mind
Bugs have been reported to MS about functionality of Find in Files. Especially VS2017 is affected. So, based on the VS version you have, something may or may not work correctly. I know that subfolders feature was affected. I've seen this searching only 3 folders deep but not deeper. Here you can look at or report new bug
Upvotes: 11
Reputation: 30403
In VS:
Go to Edit > Find and Replace > Find in Files, which opens this screen:
Then press the ellipsis button to the right of Look In that's circled in red above.
That opens a screen where you can select folders:
use the right arrow between the lists (circled in red) to select which folder(s) to search, choose the ones that contain the .proj or .sln files you want searched.
Press OK
Back on the Find and Replace screen you can add the filter (similar to that mentioned in the other answer) if you want just project files, e.g. .??proj;.sln;.asax;.ashx
And then finally the Find buttons will be enabled, hit Find All and that will return results that include project files:
NB: @T.S. just made the very good point that I have 'Display file names only' ticked in the screenshots. You don't need that to make this work, I had that ticked because I have minified files in my project and they cause the Find Results window to slow to a crawl if they are included in the search results!
Upvotes: 19
Reputation: 11
In Visual Studio:
It will search the text in all files including .sln and .csproj files.
Upvotes: 1
Reputation: 7630
You can do search in project items in visual studio. The only way to search in csproj and sln files you should do use for example windows explorer. this may be helpful
Upvotes: -1