Repository navigation
Publish module.config once, also through the Commerce package - #213
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #108.
The problem
The package delivered
module.configin two ways:copyToOutput, so NuGet copied it to the output and publish folders.CopyModule.targets, which copies it tomodules/_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 asContent.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.configat all.The fix
All of it is in
CopyModule.targets:Content.ComputeResolvedFilesToPublishListand 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 websites against the package, on SDK 10.0.301 on Windows. The result is the exit code of the publish and the number ofmodule.configfiles in the output.masterNETSDK1152NETSDK1152publish --no-build, same configurationNETSDK1152<Content Update>workaround from the issueErrorOnDuplicatePublishOutputFiles=falseOn 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
EPiServer.Events.ChangeNotificationassembly, which looks like a gap in those test sites, so for Commerce only the published file was checked.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