This article applies to: ✔️ .NET Core 2.1.100 SDK and later versions
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 build error similar to the following:
Duplicate 'Compile' items were included. The .NET SDK includes 'Compile' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultCompileItems' property to 'false' if you want to explicitly include them in your project file.
Duplicate 'EmbeddedResource' items were included. The .NET SDK includes 'EmbeddedResource' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultEmbeddedResourceItems' property to 'false' if you want to explicitly include them in your project file.
To resolve the errors, do one of the following:
Remove the explicit Compile, EmbeddedResource, or None items that match the implicit ones listed on the previous table.
If you only disable Compile globs, Solution Explorer in Visual Studio still shows *.cs items as part of the project, included as None items. To disable the implicit None glob, set EnableDefaultNoneItems to false too.
WPF projects
You might hit this error in a WPF project due to duplicate ApplicationDefinition or Page items. To resolve the error, can you disable default items using an MSBuild property. For example, to disable default Page items in a WPF project, set EnableDefaultPageItems to false:
Μπορείτε να βρείτε την πηγή για αυτό το περιεχόμενο στο GitHub, όπου μπορείτε επίσης να δημιουργήσετε και να εξετάσετε ζητήματα και αιτήματα έλξης. Για περισσότερες πληροφορίες, ανατρέξτε στον οδηγό συνεργατών.
.NET σχόλια
.NET είναι ένα έργο ανοιχτού κώδικα. Επιλέξτε μια σύνδεση για να παρέχετε σχόλια:
Συμμετάσχετε στη σειρά meetup για να δημιουργήσετε κλιμακούμενες λύσεις AI που βασίζονται σε πραγματικές περιπτώσεις χρήσης με συναδέλφους προγραμματιστές και ειδικούς.