Visual Studio 2012 "Find in Files" searches far beyond the solution when "Entire Solution" is specified - visual-studio-2012

While performing Find and Replace operations in Visual Studio 2012; using the Find in Files/Replace in Files dialog window, setting the "Look in" scope to "Entire Solution", and using Regular Expressions on all file types, Visual Studio is busy searching the WHOLE HARD DRIVE! Some of my searches take a very long time and when I look at the Visual Studio Status Bar, it shows the currently searched directory/file is something well outside of the solution folders - sometimes it is even searching the C:\Windows\System32 directory or similarly irrelevant locations.
Has anyone else seen this behavior? More importantly, does anyone have a solution to fix it, so my search and replace operations stick to the solution files and don't waste time searching the other million files on the computer?

I've not had it searching the whole drive, but I have had it return matches from files outside my project (this in VS 2010). In my case deleting the .suo file appeared to fix this issue.
My suspicion is that the files being searched are files I stepped into during a debugging session (or more accurately stepped out of my code into the calling code). Somehow these files are remembered and included in searches.
This wouldn't explain a full drive search, but could explain my "out of solution" results

I was having a similar problem with Visual Studio 2013 with Update 4 installed - in my case I was getting search results from files that had been in the Miscellaneous Files 'Project', even after removing them from Miscellaneous Files.
Deleting the .suo file from the solution directory solved the problem; however, doing so causes VS to forget which files you had open in the solution (and probably some other things).

Still occurring in Visual Studio Enterprise 2017, Version 15.8.6.
Deleting the .suo file (found in .\.vs\YourSolutionName\v15\) and rebuilding the solution fixed the issue.
I suspect it's known directory/targeted directory to search was being cached there because the Find Results would show up very quickly. Indicative of it not searching the "whole hard drive", or even my whole mapped workspace "Local Folder". Typically if I am performing a search on even a more parent branch in source control, it will take close to a minute.

For me the solution was to move the file .sln into the solution directory.

Related

Is Android Studio 4+ text search across all files gone?

In previous versions of Android Studio before 4.0, you can search across all text based files.
Now, not only is the short cut to launch the search is gone. The "search everywhere" command only search across file names.
Did I miss something in the update.
You can still search across all files for specific text in AS 4+ by using:
ctrl+Shift+7
or from menu:
Edit > Find > Find in path
In case you don't know, the shortcut for 'Search everywhere' is achieved by quick double-press Shift. I have got AS 4.1. It works well, maybe something is missed when you updated, maybe the restart is required after the update. If restarting doesn't help, you can 'invalidate caches / restart'. Sometimes, IDEA/AS goes mad, fails to find references.

Find in Entire Solution in Visual Studio 2012 gets quite a lot of result from Temp folder

In Visual Studio 2012, I tried to do some search in:
Find in Files->Entire Solution, then I get quite a lot results from files in
C:\Uses\myusername\AppData\Local\Temp\
. The files take the name like tmpE11.tmp.cs or tmpFBEE.tmp.cpp, the contents are identical to some of the files in my solution.
My guess is that it is caused or auto-generated by some crashes, but why are they reachable by the search? I doubt if I can simply delete them or not.
Maybe this is related to a bug reported, where lots of tmp files created and are then included in the Find Results. If I clear the 'Miscellaneous Files Folder' the search does not include the temporary files.
To display the 'Miscellaneous Files Folder' (see https://msdn.microsoft.com/en-us/library/36bhtx7w.aspx):
List item
On the Tools menu, click Options.
In the Options dialog box, expand the Environment node and select Documents.
Select Show miscellaneous files in Solution Explorer.
Specify the number of documents you want to appear in the folder.
In Visual Studio 2013 you can limit the contents to 0 which effectively prevent inclusion.

Move solution in Source Control

I have a project under source control in Visual Studio 2012 using TFS2010. When I added this project, the solution was not added in the correct file folder location. I want to move the solution, but every time I try to do it within the Source Control Explorer I encounter an error: "The project file 'path/to/project.csproj' has been moved, renamed, or is not on your computer." What is causing this error? What is the proper way to move the solution to where I want it to be?
Move the solution file in TFS (this is more relevant if you have history you want to maintain)
Open the solution, it will complain that it can't load your projects, either edit the path to the project in the properties window, or remove each project and then re-add it. Check-in your changes
Delete the .suo file and try once. Has helped me in the past. This file is usually hidden. Restart VS after deleting.
The problem is the solution file has relative paths to the project files. I usually do any moving around when I first create the solution (before there are projects in it). However, in your case I would just use Source Control Explorer to move the solution, then edit the .sln file in a text editor and fix up the relative paths to the proj files.

Any way to apply an exclude list to the Visual Studio "Navigate To"-list?

I'd like to exclude code-generated files from the Edit > Navigate To-list which appears when hitting Ctrl+, in Visual Studio 2013, as these files are never to be modified by me manually and in those rare cases where I want to see the contents of them, I'll use the solution browser. Is there any way to do this? They produce a lot of noise in my search and greatly reduces the value of the Navigate to-function.
Edit Nov 2016: added an image for illustration in VS 2015. Very much an issue still. The first search hit is a .g.cs file in the obj-folder:
I assume that by "code-generated files" you are referring to files such as .designer that are also part of the solution (and found in solution explorer). After quite a bit of research into Navigate To I was unable to find any reference to such a configuration option. Currently there appears to be only 3 options for configuration (discussed in the MSDN blog below). A possible work around would be to leverage the built in filtering features of Navigate To (#, Capitalization and Whitespace) that are new to VS2013 as outlined in this MSDN blog:
http://blogs.msdn.com/b/mvpawardprogram/archive/2013/10/22/visual-studio-2013-navigate-to-improvements.aspx
Another article I found in my research: http://weblogs.asp.net/scottgu/archive/2009/10/21/searching-and-navigating-code-in-vs-2010-vs-2010-and-net-4-0-series.aspx
UPDATE: I use the ReSharper plugin and only after posting this answer realized there is a Filter results from generated files feature to exclude generated files and is discussed at the link below. Though it does not pertain to Navigate To, it may provide a satisfactory alternative:
http://www.jetbrains.com/resharper/webhelp/Reference__Options__Environment__Search_and_Navigation.html
UPDATE (12/1/2015): Now that some time has passed I decided to do a little more research and found a similar request posted on SO here. I found this to work pretty well, and VS will even save the list for you.

Visual Studio 2012 - Content Window Tabs Not Remembered on Re-Start of VS2012

My tabbed open documents are stuck on the same three files for over a month now. When I save and close VS2012 the open files I was working on do not come back on restart. I get the same three old files regardless. I am assuming that the tab cache has issues or something and needs to be cleared, but don't know where to go for this. Has anyone else run into this glitch? Any solutions to refresh the tab'able items so this functionality works correctly again?
It has been three weeks with no answers ... so I finally figured this out on my own. I hate answering my own questions, but here it is:
The SUO file is where all the settings, startup project, and cached user options are kept. With large projects there are times where the .suo file becomes corrupted or too large causing sluggish, or odd behavior with these options. Case in point the outlier I ran into with my open classes not being remembered.
Solution:
Simply delete the .suo file. Visual Studio will create a fresh one for you. I did this and it solved the problem.
NOTE: if you do not see a .suo file in your Solution's root directory try showing hidden files.

Resources