18

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?

Ciel
  • 4,290
  • 8
  • 51
  • 110
  • 1
    I too would like to exclude the those folders (`node_modules`, `jspm_packages`, etc). Did you have any luck in working around this issue? – Jaans Jan 05 '16 at 08:27

2 Answers2

38

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

Community
  • 1
  • 1
joanygaard
  • 501
  • 4
  • 7
  • thanks for this. My problem is the node_modules folder is already visible inside the project. I've made the folder hidden in explorer but the project is still 'seeing' the folder. Any ideas? – Drammy Apr 13 '16 at 08:22
  • 3
    Regarding the nested node_modules: this behaviour has been improved in npm 3.x so that the nesting is no longer as deep. If relying on Visual Studio to do your npm installing, you can point it at an external version instead of the old embedded version in Options->Projects and Solutions->External Web Tools. – ADBailey Aug 01 '16 at 13:22
  • You save my time. Thank you. – ebattulga Dec 26 '16 at 13:06
  • Right click the folder > properties > Tick on hidden did the trick. – PAVITRA Jan 24 '17 at 12:18
1

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.

Andrew Gunn
  • 95
  • 1
  • 8