代码之家  ›  专栏  ›  技术社区  ›  developer82

.NET Core 1.1-获取“包含重复的‘内容’项目”

  •  5
  • developer82  · 技术社区  · 7 年前

    我已将我的VS2017更新至最新的15.3.0版本,并已安装。NET核心SDK 2.0(我想将现有的.NET 1.1应用程序升级到2.0)。

    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'
    

    在它指向的问题文件下 C:\Program Files\dotnet\sdk\2.0.0\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets

    <EnableDefaultContentItems>false</EnableDefaultContentItems> 给我的 .csproj 文件但之前没有,我不知道加上这行意味着什么。

    有一件事真的让我困扰,那就是它指向的源文件在 dotnet\sdk\2.0.0

    我该如何解决这个问题?我希望在升级到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>
    

    < PropertyGroup 它起作用了。但是我不知道这是什么意思或者为什么突然需要它。。。

    2 回复  |  直到 7 年前
        1
  •  7
  •   Martin Ullrich    7 年前

    移除 <ItemGroup> 元素包含

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

    此项目已包含在 Microsoft.NET.Sdk.Web

        2
  •  1
  •   Stefan Steiger Marco van de Voort    7 年前


    1. 右键单击“wwwroot”,选择“包含在项目中”

    错误现在消失了。