'How to exclude file/folder from visual studio project?

I can't find any option or command to make a file or folder to be excluded from my visual studio project. (csproj, jsproj ... )

There is the option to include files and folders in the Solution Explorer -> Show All Files -> left mouse click on target -> Include In Project.

but there is no option for exclude...

I'm using VS 2015.

I noticed that the option for exclude was available in VS 2008 and 2010. by this doc:

https://msdn.microsoft.com/en-us/library/0ebzhwsk(v=vs.100).aspx

any solution?

thanks

EDIT:

The problem is only in jsproj type of project (Apache Cordova project for example). excuding in csproj is working great.



Solution 1:[1]

enter image description here

I have the German version and it shows "exclude from project", when right-clicking on the Item/File/Directory

I also can use "Project > Exclude selected File from Project".
It could look like your Installation is broken. Maybe update/reinstall VS to solve the problem...


btw.: This is VS2015...


EDIT ?1: This thread does also complain about the context menu option not showing up, but I could not find the answer.


EDIT ?2: You could edit your .csproj-file using a text editor to manually include or exclude different files, but it is always a bit ponderous to close the project, edit the file and reopen the project....

The appropriate tag is named <ItemGroup> and should look like this:

<ItemGroup>
  <Content Include="css\foundation.css" />
  <Content Include="css\foundation.min.css" />
  <Content Include="css\main.css" />
  <Content Include="img\my_image.png" />
 ...
</ItemGroup>

Simply change the first attribute from Include to Exclude. If this does not work, try to uncomment the specific files/directories:

<ItemGroup>
  <!--
  <Content Include="file\to_be.ignored" />
  -->
 ...
</ItemGroup>

Solution 2:[2]

Visual Studio 2019:

Example: remove relative folder node_modules

add this to csproj file

<ItemGroup>
  <Compile Remove="ClientApp\node_modules\**" />
  <Content Remove="ClientApp\node_modules\**" />
  <EmbeddedResource Remove="ClientApp\node_modules\**" />
  <None Remove="ClientApp\node_modules\**" />
</ItemGroup>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 lost in binary