Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude/Ignore a folder in Visual Studio 2015 (Web Project)

I have a web project in Visual Studio 2015, and a few folders in it that I need, but don't really want being pulled into Visual Studio; These are your normal folders, node_modules,bower_components, etc. Nothing fancy about them.

However I cannot find a way to "ignore" or "exclude" them. In the past, I could right click a folder and simply tell it to exclude it, and it worked; But since upgrading to VS2015, that option seems completely gone.

I thought perhaps it was in the .gitignore, but tampered with that to no avail. Is there some new secret to this?

like image 483
Ciel Avatar asked Sep 25 '15 22:09

Ciel


2 Answers

I've spent quite some time looking around for how to make NPM and bower work smooth with a website-project - and the main problem is that the node_modules-folder is so deeply nested. Causes all kinds of path-too-long-issues. This is with visual studio 2015 - website project created with older Visual Studio.

If the Visual Studio project type is "web application", and you have a .project-file for your web project, you should be able to right click files/folders in the solution explorer, and select "exclude".

However, if your Visual Studio project type is "website", there is no .project-file - you cannot exclude files and folders from Visual Studio. The trick is to set the hidden-attribute on files or folders with windows explorer - Visual Studio will then ignore them. Don't try to set hidden recursive on all subfolders - just the "outer" folder is fine.

This worked fine for me for node_modules. NPM-integration and command line NPM still works. I also removed the read-only-attribute from the folder.

If possible, consider converting your project to web application.

Read more here:

Other stack-overflow issue about website-type projects

About web application project vs. website project

About excluding items

like image 185
joanygaard Avatar answered Sep 18 '22 18:09

joanygaard


After installing ASP.NET 5 Beta 8, right click on the folder in Visual Studio, and select "Hide from Solution Explorer".

The relevant files for upgrading to Beta 8 are either DotNetVersionManager-x64.msi or DotNetVersionManager-x86.msi (depending on what your system supports), and WebToolsExtensionsVS14.msi.

like image 21
Andrew Gunn Avatar answered Sep 17 '22 18:09

Andrew Gunn