Skip to content

Publish module.config once, also through the Commerce package - #213

Merged
frederikvig merged 2 commits into
masterfrom
fix/publish-duplicate-module-config
Nov 7, 2026
Merged

frederikvig merged 2 commits into
masterfrom
fix/publish-duplicate-module-config

Conversation

@frederikvig

@frederikvig frederikvig commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Closes #108.

The problem

The package delivered module.config in two ways:

  • As a content file with copyToOutput, so NuGet copied it to the output and publish folders.
  • Through CopyModule.targets, which copies it to modules/_protected/... in the site's folder on build. The Shell reads it from there when running locally, but on the next evaluation the Web SDK also picks it up as Content.

So any publish after a build has two files for the same path and fails with NETSDK1152. A clean publish doesn't, because the local copy isn't there when the project is evaluated.

Content files also aren't passed on by default to a site getting a package through another one, so a clean publish of a site using the Commerce package had no module.config at all.

The fix

All of it is in CopyModule.targets:

  • The local copy is excluded from Content.
  • The targets replace NuGet's item with one of their own, which also reaches a site using the Commerce package.
  • A new target runs after ComputeResolvedFilesToPublishList and leaves exactly one file for this path in the publish list: the one from this project's package.

The last one is there because projects can restore different versions of the add-on, and items flow up through project references. Without it, a site and a library on different versions had two sources for one path.

The package's content file still copies to the output, so a project excluding the targets still gets the file.

Behavior change

The published file now always comes from the package. A site that removed the package's file from its publish used to get the copy in its own folder instead, so a build step editing that copy no longer changes what's published. This is in the changelog. A public code search found no site doing this.

Results

I packed the add-on and published fresh dotnet new web sites against the package, on SDK 10.0.301 on Windows. The result is the exit code of the publish and the number of module.config files in the output.

Case master This branch
Clean publish 0, 1 file 0, 1 file
Publish twice NETSDK1152 0, 1 file
Build, then publish NETSDK1152 0, 1 file
Build, then publish --no-build, same configuration NETSDK1152 0, 1 file
Through Commerce, clean publish 0, no file 0, 1 file
Through Commerce, build then publish 0, 1 file 0, 1 file
With the <Content Update> workaround from the issue 0, 1 file 0, 1 file
With ErrorOnDuplicatePublishOutputFiles=false 0, 1 file 0, 1 file

On this branch, a Commerce site with a library on an older version of the add-on also gives 0 and 1 file, on a clean publish and after a build. I didn't run that case on master.

The review ran a wider matrix on this fix: 54 scenarios with stub packages, each on clean publish, build then publish, and --no-build, all 0 and 1 file. Its controls failed on the previous commit of this branch. Real packages on CMS 13.1.0 sites also gave 0 and 1 file. A direct site booted and found the module from both its project folder and the publish output, with the add-on page returning 200 for an admin and 302 for anonymous.

Not tested

  • Linux, on this fix. The new target compares paths using the platform's separator, which is reasoned from MSBuild's source but hasn't been run. CI is Windows only.
  • Booting a site through the Commerce package. The review's minimal Commerce sites failed at startup on a missing EPiServer.Events.ChangeNotification assembly, which looks like a gap in those test sites, so for Commerce only the published file was checked.
  • Visual Studio's publish and solution explorer.

Follow-up worth considering

This is the second fix to how this file gets delivered. The Shell finds the module through a physical file, so MSBuild has to place it for every kind of site. Serving the manifest from the assembly would remove all of this, and the review got a variant of that booting on CMS 13.1.0. It's new runtime code, so it doesn't belong here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GUDE6qHSSrhDDLNMCQ5suJ

frederikvig and others added 2 commits November 7, 2026 08:44
The package copied module.config to the site's output itself, and its
targets copied it to the site's folder on build, where the next evaluation
picked it up as content. Both were published to the same path, which fails
with NETSDK1152 on any publish after a build.

Excluding the local copy alone would leave a site using the Commerce package
with no module.config, as content files aren't passed on to a site getting
a package through another one. So the targets now publish the file from the
package themselves, which also fixes a clean publish of such a site.

Closes #108

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUDE6qHSSrhDDLNMCQ5suJ
The previous fix added one item for the package's file in every project
importing the targets, and those items flow up through project references.
A site and a library on different versions of the add-on had two sources for
one path, so the publish failed with NETSDK1152 where master could pass, and
a local copy reaching the publish another way failed the same way.

The file is now settled in the list of files to publish, after everything
else has added to it. The package's content file copies to the output again,
so a project excluding the targets still gets the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUDE6qHSSrhDDLNMCQ5suJ
@frederikvig
frederikvig merged commit c4a964c into master Nov 7, 2026
1 check passed
@frederikvig
frederikvig deleted the fix/publish-duplicate-module-config branch November 7, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotnet publish error: Microsoft.NET.ConflictResolution.targets(112,5): error NETSDK1152: Found multiple publish output files with the same relative path

1 participant