NETSDK1022

Michał 1064 11 Reputation points
2021-03-11T11:12:49.537+00:00

Hello! Every time I create a new Net Core console project ("Hello world") and add a new class, I get the NETSDK1022 error ("duplicated compile items"). I have already reinstalled Visual Studio 2019, probably deleted all possible files and imported the configuration from a properly functioning VS installation on another computer. In this case, nothing helps. When I add a new class then Visual Studio adds a section to the project file:
<ItemGroup>
<Compile Include = "Class1.cs" />
</ItemGroup>
which causes the error. If I delete it, the project will compile correctly. But I have to do this after adding each new class. In other VS installations, this section is not added. Why in this case VS adds this section? What settings can cause this? Thank you in advance for your answer.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,240 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,988 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 27,271 Reputation points Microsoft Vendor
    2021-03-12T09:37:01.203+00:00

    Hello @Michał 1064 ,

    Thank you for taking time to post this issue in Microsoft Q&A forum.

    I tested on my side, but I failed to reproduce your issue(Visual Studio 2019 Community). The .NET Core Console project worked well. I think this is an issue which is related to environment, extensions or VS IDE(under certain conditions).

    There is a similar thread: Prevent VS from adding explicit compile tags to csproj and this issue has been reported in our Developer Community, please check this thread: Compile elements added to project file when EnableDefaultCompileItems was not set to false, and vote, add comments then follow that thread, if this is a potential issue, Visual Studio Product Team will help to fix it.

    Feel free to contact us if you have any concern.

    Best Regards,
    Tianyu

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      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.