Error Knowledge Base .NET NETSDK1152

NETSDK1152: Found multiple publish output files with the same relative path

Two files in the publish graph would land at the same relative output path, so the SDK fails instead of overwriting one silently.

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.

Typical Output

error NETSDK1152: Found multiple publish output files with the same relative path: appsettings.json.

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>

Need help or found a mistake? Contact RepoFlow support for questions.

Join our mailing list