.NET Core 1.1 - Getting Duplicate 'Content Elements Has Been Enabled "

I updated VS2017 to the latest 15.3.0 and installed the .NET Core SDK 2.0 (I would like to upgrade my existing .NET 1.1 application to version 2.0).

Now, when I open my project, which compiles in order (did not change anything in it), and I try to compile, I get:

Duplicate 'Content' items were included.
The .NET SDK includes 'Content' items from your project directory by default.
You can either remove these items from your project file, or set the 'EnableDefaultContentItems' property to 'false' if you want to explicitly include     them in your project file.
For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'wwwroot\index.html'

In the problem file, it points to C:\Program Files\dotnet\sdk\2.0.0\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets

I read online and I can solve this by adding <EnableDefaultContentItems>false</EnableDefaultContentItems>to my .csprojfile. But this has not happened before, and I'm not sure what adds this line.

One day, it really bothers me that the source file it points to is in dotnet\sdk\2.0.0, and as I mentioned, the project still remains .NET Core 1.1. All I have done so far is to install the update for VS2017 and 2.0 SDK.

? , , 2.0.

csproj :

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Content Include="wwwroot\index.html" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="IdentityServer4" Version="1.5.2" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.1" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
    <PackageReference Include="NLog.Web.AspNetCore" Version="4.4.1" />
  </ItemGroup>
  <ItemGroup>
    <Content Update="appsettings.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="web.config">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <None Update="NLog.config">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

</Project>

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

+4
2

<ItemGroup>,

<Content Include="wwwroot\index.html" />

Microsoft.NET.Sdk.Web .

+5

.
:

  • " "
  • "wwwroot", " "
  • "wwwroot", " "

.

, .

0

Source: https://habr.com/ru/post/1683786/


All Articles