Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2012 - Hide folders from solution explorer?

Is it possible to hide folder in Visual Studio 2012 solution explorer window? I have multiple folders/files that I don't plan to use and they are just cluttering the interface and it's harder to find things.

It just seems pretty illogical that you can toggle "Show Hidden Files" but you cannot actually hide any files.

Example

enter image description here

Why

WebApi project includes automated help generation that I want to use, however it includes multiple folders that it needs to function. All I care about is Controllers/Models since I'm building the Api itself. But if I delete/remove from project those files than help generator won't work.

like image 368
Stan Avatar asked Jul 30 '13 17:07

Stan


People also ask

How do I hide files in Solution Explorer?

With the latest Visual Studio you just need to right-click the folder/file and chose "Hide from Solution Explorer".

How do I hide Solution Explorer in Visual Studio?

You can close any panel using Shift + Esc . So hit the key combination with the focus on the solution explorer and it will close.


2 Answers

Since you want the files to still be accessible, as opposed to just excluding them, you can modify the csproj file itself. Unload your project from the solution, right-click and select edit. Scroll down to where your folders are displayed (I tested with a folder called "TestFolder" and a file within it called TestClass.cs.

<Compile Include="TestFolder\TestClass.cs">        
    <SubType>Code</SubType>
</Compile>

Create a new child tag called Visible and set the value to false.

<Compile Include="TestFolder\TestClass.cs">    
    <Visible>false</Visible>    
    <SubType>Code</SubType>
</Compile>

Save and reload the project and the files should no longer be visible but accessible. I just did a quick test and it seemed to work fine (but YMMV).

like image 189
keyboardP Avatar answered Oct 14 '22 01:10

keyboardP


Hiding folders is almost certainly a bad idea. Remember that hiding a folder is not the same as excluding it from the solution - all hidden items can still be used elsewhere in the code, can be referenced by the build, and get updated when you pull the latest version from source control.

That is the reason why it was never available for project folders - so that people cannot easily confuse their workmates.

Having said that, it is possible to hide folders on the solution level - I guess mostly because it's quite common to have documentation, shared libraries etc on that level. To hide a solution folder, you right click on the folder, and select "Hide Folder" (to unhide, you'd right click on the solution itself and select "Unhide folders")

enter image description here


As for your screenshot where you want to hide Area, Scripts etc - I suspect you're working alone and just started learning MVC - otherwise it wouldn't make sense to hide those folders. They contain legitimate code which is used to run the application. Hiding it is the same as hiding Program.cs in a console project for the sole reason that you prefer a smaller tree in the solution.

I do agree that Solution Explorer becomes unmanageable at some point - but instead of messing up with it, I'd recommend to try other tools - Visual Studio "navigate to" options or Resharper (I use the latter).

like image 41
andreister Avatar answered Oct 14 '22 00:10

andreister