Error NETSDK1022: Duplicate 'Content' items were included

Kalpana 21 Reputation points
2024-11-28T01:59:55.2933333+00:00

Hi,

I have a web application that was built using .Net core 3.1. There has been an update to the sdk from 8.00 to 9.00 and is now giving issues and the error thrown is this : -

The static files are located in a folder called content and there was no issue till the update. How can I rectify this. I would need the json and config files as well to be included

##[error]C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets(213,5): Error NETSDK1022: 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: 'Content\docs\nuget.config'; 'Content\docs\packages.config'; 'Content\docs\.dependencymap.json'; 'Content\docs\.links.json'; 'Content\docs\.manifest.json'; 'Content\docs\.publish.json'; 'Content\docs\.xrefmap.json'; 'Content\docs\articles\a365fo\supplementary-functionality\document-management-extensions\toc.json'; 'Content\docs\articles\sales\hidden\toc.json'; 'Content\docs\articles\dealerportal\reports\toc.json';  
			
Developer technologies | ASP.NET | ASP.NET Core
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-11-28T02:52:15.8733333+00:00

    Hi @Kalpana

    NETSDK1022: Duplicate items were included

    For this issue, you can check NETSDK1022: Duplicate items were included.

    Starting in Visual Studio 2017 / MSBuild version 15.3, the .NET SDK automatically includes items from the project directory by default. These items include Compile and Content targets. This behavior simplifies project files.

    However, if you explicitly define any of these items in your project file, you're likely to get a NETSDK1022 build error.

    To resolve the errors, try to open the project file (double click your project name, the project file name is {projectname}.csproj), and then do one of the following:

    • Remove the explicit Content items that match the implicit ones listed on the error message.
    • Set the EnableDefaultContentItems property to false to disable all implicit file inclusion.

    After that, clean and rebuild the application.

    Finally, if still not working, try to share your project file(.csproj).


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Dillion

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.