Visual Studio 2012 Solution Explorer Search doesn't search cshtml files - search

When I refactored a namespace in Visual Studio 2012 MVC 4 Web project, the razor files that included the "#model MyFirstWeb.Domains.LoginModel" did not get touched which caused an exception when compiling for first use.
It isn't that much of a deal but rather odd?, can I register the cshtml as a file extension to search?
If I use the "Search Solution Explorer" to try and file the text I know exists in that file I get nothing?
What am I missing?

Here's a blog post that explains the ins and outs of the Solution Explorer Search:
http://www.schwammysays.net/visual-studio-2012-tip-search-in-solution-explorer
Basically, you're searching the Solution Explorer, not the files, so anything that's visible in the Solution Explorer will be searched. Luckily, the Solution Explorer now includes logical structure as well.

This appears to be a known bug in VS 2013 R1, which was identified and then closed but users are still having issues. Although outside of the solution explorer, you can use the 'Ctrl + ,' search to these filetypes in your solution.
The related tickets are here....
http://connect.microsoft.com/VisualStudio/feedback/details/801838/solution-explorer-search-doesnt-include-js-or-cshtml-results
and
http://connect.microsoft.com/VisualStudio/feedback/details/801836/solution-explorer-doesnt-search-files-projects-inside-solution-folders

Related

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.

How to choose which file to debug in Visual Studio 2012 prof

Kinda stupid question, but I've only been using this IDE for two days now. I havent found anything in google yet and I figured that once in a while you're entitled to a stupid question:
I have a project (or solution as Microsoft chose to call it) with two .cs-files. When I click on debug, it's alwys the same file that opens. How can I get VS to open the other .cs-file?
It sounds like you have multiple static Main methods in your project. If that's the case then you have to set the startup object to the object that you want to run.
Right-click on the project in the Solution Explorer and select
Properties (or select Project >> Projectname Properties from the
toolbar).
On the Application form, select the appropriate value
for Startup Object.

Visual Studio 2012 random bug or fail by me

The problem
Yeah, so I am having quite annoying problem where to I have not been able to find any solution from Google. The problem comes up in both situations starting up a new project or opening up old working one, all I get is emptiness everywhere, see picture below.
What i have already tried
I have tried reinstalling the whole program couple times and I have patched it.
Picture: http://i.imgur.com/XqJgwKJ.png
The solution explorer may not show up by default. You can show it with:
Application menu: View > Solution Explorer
Shortcut: Ctrl + Alt + L
I think you just don't have your solution explorer open and visual studio doesn't open any file by default.
The solution explorer shows you all of the files and folders in the current solution and let's you open them.
Open it using View > Solution Explorer or press Strg + Alt + L.

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

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.

Quick Find / Find in Files scope in Visual Studio 11 Beta

In Visual Studio 2008 and 2010, the "Quick Find" and "Find in Files" window had different search scopes. I was using the Quick Find window to search the current document and the find in files window to search the entire solution.
In the new beta version, changing the scope in one window impacts the other window too. Is there a way to go back to the previous behaviour?
Thank you
There is a fix for this (VS11 BETA ONLY Find Settings Seperator)
I found it at: http://blogs.msdn.com/b/visualstudio/archive/2012/04/11/improving-find-amp-replace-in-visual-studio-11-beta.aspx
Shortcut to fix

Resources