Fix NETSDK1152 Duplicate Publish Output Paths in .NET
Quick answer. Use the error’s source paths to find each contributor. Keep the item owned by the host and remove, rename or relocate the other content at its source.
Applies to. .NET SDK and MSBuild
What does the error look like?
Two referenced projects both contribute an appsettings.json file to the same publish destination.
How do you diagnose the cause?
Inspect publish items and project references. A shared library that contains app configuration should not publish it to the host root unless intended. Use a distinct relative destination when both files are needed. Keep collision detection enabled.
Worked example
Use the relevant portion below in a development or staging environment. Match the existing application’s packages, settings, and environment before applying the change.
<!-- In the project that should not publish its appsettings.json -->
<ItemGroup>
<Content Update="appsettings.json" CopyToPublishDirectory="Never" />
</ItemGroup>In Blogger preview, you can select the snippet and copy it directly.
How do you verify the fix?
| Check | Expected behavior |
|---|---|
| Verify publish output | Publish succeeds with one deliberate file at each relative path. |
| Repeat with the original failing input or setup | The relevant error is reproducible under the old conditions and resolved under the corrected conditions |
These are expected results to validate in your environment.
What should you check first if the error returns?
Use the error’s source paths to find each contributor. Keep the item owned by the host and remove, rename or relocate the other content at its source.
Comments
Post a Comment