Fix it fast
Most likely: The project explicitly includes files that SDK-style projects already include automatically, usually duplicate Compile, Content, or None items.
Confirm this is your error
Match the output and confirm you are troubleshooting the same failure.
error NETSDK1022: Duplicate 'Content' items were included. The duplicate items were: 'appsettings.json' Check the cause
Run focused checks to identify what is failing in this environment.
dotnet build -v minimal
grep -n "<Compile\|<Content\|<None\|EnableDefault" *.csproj
dotnet msbuild -preprocess:project.preprocessed.xml Apply the safe fix
Use the smallest safe change that addresses the confirmed cause.
# Best fix: remove the explicit duplicate Include from the project file and rely on SDK defaults.
# Look for the duplicate filename from the NETSDK1022 message in .csproj, .props, or .targets files.
# Only if you intentionally manage every item manually, disable the relevant default item group.
# Example properties: EnableDefaultCompileItems=false, EnableDefaultContentItems=false, EnableDefaultNoneItems=false
dotnet build Verify it works
Repeat the relevant checks and confirm the original error is gone.
dotnet build
dotnet msbuild -preprocess:project.preprocessed.xml Avoid unsafe shortcuts
Keep security and data protections in place while troubleshooting.
- Do not disable all default items just to fix one duplicate unless the project intentionally manages every item manually.
- Do not keep old explicit globs after migrating to an SDK-style project.
- Do not fix only the visible project file if imported
.propsor.targetsfiles add the duplicate.
What Broke in the Build
The project explicitly includes files that SDK-style projects already include by default, creating duplicate items.
Fix the underlying build failure
Remove redundant Compile or Content entries from the project file, which is usually the best fix, or disable the relevant defaults with EnableDefault*Items=false if you want full manual control, and rebuild with dotnet build.
Validation
Re-run the failing command and confirm the original code/message is gone, and confirm expected artifacts or outputs exist (packages restored, build/publish succeeds).
Why the Build Fails
Usually this comes down to leftover explicit globbing remains after migrating to an SDK-style project, custom includes overlap with the SDK defaults, or imported props or targets add the same items twice.
Prove the Build Path Is Clean
dotnet build succeeds without NETSDK1022.
The duplicated file appears only once in the evaluated build items or binlog.
Mechanism
SDK-style projects add Compile and Content items automatically from the project directory. Explicit ItemGroup entries that overlap those defaults trigger NETSDK1022.
Keep Build Prerequisites Consistent
To prevent this, keep SDK-style project files minimal and rely on defaults where possible, and validate migrations in CI with a clean build rather than incremental state.
Docs and source code
NETSDK1022 message template
User-facing message template explaining default includes. - GitHub
<data name="DuplicateItemsError" xml:space="preserve">
<value>NETSDK1022: Duplicate '{0}' items were included. The .NET SDK includes '{0}' items from your project directory by default. You can either remove these items from your project file, or set the '{1}' property to '{2}' if you want to explicitly include them in your project file. For more information, see {4}. The duplicate items were: {3}</value>
<comment>{StrBegins="NETSDK1022: "}</comment>
</data>