Duplicate 'Content' items were included. The .NET SDK includes 'Content' items from your project directory by default

1. Click 'Show All Files' in Solution Explorer
2. Right-click over 'wwwroot' select 'Exclude From Project'
3. Right-click over 'wwwroot' select 'Include in Project'

So I ran into this same issue. I didn't want to turn off DefaultCompileItems because I knew that wouldn't "fix" the problem. So I unloaded my project and opened the .csproj file in text mode in Visual Studio and saw this.

<ItemGroup>
    <Content Include="wwwroot\css\custom-bootstrap-navbar.css" />
    <Content Include="wwwroot\images\friends-eating\image1.jpg" />
    <Content Include="wwwroot\images\friends-eating\image2.jpg" />
    <Content Include="wwwroot\images\friends-eating\image3.jpg" />
</ItemGroup>
<ItemGroup>
    <Folder Include="wwwroot\images\friends-eating\" />
</ItemGroup>

When I commented out the first ItemGroup block, it worked. What I assume is happening is that the project is adding the entire \images\friends-eating\ folder and then adding each individual image, causing a duplication.

As far as the custom css and js, the project automatically adds wwwroot\css and wwwroot\js so if you have an individual file added (like wwwroot\css\custom-bootstrap-navbar.css) it'll count as a duplicate.


This worked in my case:

 <PropertyGroup>
    ...
    <EnableDefaultContentItems>false</EnableDefaultContentItems>
  </PropertyGroup>