Fix it fast
Most likely: Two publish items would write to the same relative path in the publish folder, often from a project reference plus a same-named content file like appsettings.json.
Confirm this is your error
Match the output and confirm you are troubleshooting the same failure.
error NETSDK1152: Found multiple publish output files with the same relative path: appsettings.json. Check the cause
Run focused checks to identify what is failing in this environment.
dotnet publish -c Release -v normal
grep -R "<Content\|<None\|TargetPath\|Link\|CopyToPublishDirectory" -n .
find . -path "*<relative-path-from-error>" Apply the safe fix
Use the smallest safe change that addresses the confirmed cause.
# Choose one source of the file: rename it, give it a unique TargetPath/Link, or exclude one copy from publish.
# For files that should not publish from one project, set CopyToPublishDirectory=Never in that project file.
dotnet publish -c Release Verify it works
Repeat the relevant checks and confirm the original error is gone.
dotnet publish -c Release
find bin -path "*publish*" -name "<filename-from-error>" Avoid unsafe shortcuts
Keep security and data protections in place while troubleshooting.
- Do not disable the NETSDK1152 error globally, it prevents silent overwrites in publish output.
- Do not delete the file blindly if another project still needs it at runtime.
- Do not fix only Debug output, verify the actual publish configuration used by CI or deployment.
What Broke in the Build
Two files in the publish graph would land at the same relative output path, so the SDK fails instead of overwriting one silently.
Fix the underlying build failure
Use the error output to identify the colliding relative path or paths.
Rename one file, change its Link or TargetPath, or exclude one from publish.
Retry with dotnet publish -c Release.
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 a project and project reference both publish a same-named content file, two content or static web asset items share the same Link or RelativePath, or custom targets modify publish items and introduce collisions.
Prove the Build Path Is Clean
dotnet publish succeeds without NETSDK1152.
The publish directory contains the intended file set with no silent overwrites.
Mechanism
Publish computes a list of files with destination relative paths under the publish directory. If two files map to the same relative path, NETSDK1152 is emitted.
Keep Build Prerequisites Consistent
To prevent this, adopt naming conventions for content files across projects, and run publish in CI for representative apps to catch collisions early.
Docs and source code
NETSDK1152 message template
User-facing publish collision message template. - GitHub
<data name="DuplicatePublishOutputFiles" xml:space="preserve">
<value>NETSDK1152: Found multiple publish output files with the same relative path: {0}.</value>
<comment>{StrBegins="NETSDK1152: "}</comment>
</data>