I have an error after add new project with template

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 năm cách đây
After i have add a new plugin project with the plugin template i get this error:

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: 'plugin.json'  Nop.Plugin.Shipping.PostNord

And i just can't figure out why...

My project file look like this:


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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  <OutputPath>..\..\Presentation\Nop.Web\Plugins\Nop.Plugin.Shipping.PostNord</OutputPath>
    <OutDir>$(OutputPath)</OutDir>
  </PropertyGroup>

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

  <ItemGroup>
    <None Remove="logo.jpg" />
    <None Remove="plugin.json" />
  </ItemGroup>

  <PropertyGroup>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>

  <ItemGroup>
    <Content Include="logo.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="plugin.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\Presentation\Nop.Web.Framework\Nop.Web.Framework.csproj" />
    <ProjectReference Include="..\..\Presentation\Nop.Web\Nop.Web.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Content Update="Areas\Admin\Views\BuilderProductAttribute\Create.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProductAttribute\Edit.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProductAttribute\List.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProductAttribute\_CreateOrUpdate.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\Create.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\Edit.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\List.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\ProductAttributeCatalogCreatePopup.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\ProductAttributeMappingCreate.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\ProductAttributeMappingEdit.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdate.Attributes.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdate.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdate.Info.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdate.SEO.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdateProductAttributeMapping.Catalog.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdateProductAttributeMapping.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\BuilderProduct\_CreateOrUpdateProductAttributeMapping.Info.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\ProductBuilder\Configure.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
    <Content Update="Areas\Admin\Views\_ViewImports.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Views\BuilderProduct\AttributeMappingProduct.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Views\BuilderProduct\Details.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Views\BuilderProduct\ProductDetails.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Views\BuilderProduct\_CatalogSelectors.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Views\BuilderProduct\_ProductBox.ProductBuilder.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Update="Views\_ViewImports.cshtml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Areas\Admin\Controllers\" />
    <Folder Include="Areas\Admin\Extensions\" />
    <Folder Include="Areas\Admin\Factories\" />
    <Folder Include="Areas\Admin\Models\" />
    <Folder Include="Controllers\" />
    <Folder Include="Data\" />
    <Folder Include="Extensions\" />
    <Folder Include="Factories\" />
    <Folder Include="Models\" />
    <Folder Include="Services\" />
  </ItemGroup>

   <!-- This target execute after "Build" target -->
  <Target Name="NopTarget" AfterTargets="Build">
    <!-- Delete unnecessary libraries from plugins path -->
    <MSBuild Projects="$(MSBuildProjectDirectory)\..\..\Build\ClearPluginAssemblies.proj" Properties="PluginPath=$(MSBuildProjectDirectory)\$(OutDir)" Targets="NopClear" />
  </Target>
</Project>
4 năm cách đây
Exclude plugin.json from your plugin project, press Ctrl + Shift + S and then include it again.
4 năm cách đây
Thank you, it worked - but why did it work?
4 năm cách đây
Exactly the same error here - tried your suggestion and it worked!  Again no idea why - any explanation you care to provide?

Thanks
4 năm cách đây
Yes, it workd. Don't know why, but it did
1 năm cách đây
yes, the operation remove the <Content include, then added <EmbeddedResource
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.