Skip to content

docs: explain why publishing a solution is discouraged - #53693

Merged
marcpopMSFT merged 3 commits into
mainfrom
copilot/add-documentation-on-publishing-solutions
Jul 2, 2026
Merged

marcpopMSFT merged 3 commits into
mainfrom
copilot/add-documentation-on-publishing-solutions

Conversation

Copilot AI commented Apr 3, 2026 •

Copy link
Copy Markdown
Contributor
  • Trim second sentence from Overview (marcpopMSFT)
  • Rewrite -r/RuntimeIdentifier bullet with precise RID-restore explanation (marcpopMSFT + rainersigwald + baronfel)
  • Add race-condition note to the -f/TargetFramework bullet (rainersigwald)
  • Note unnecessary-rebuild caveat and traversal-project alternative in step 3 (rainersigwald)
  • Add -f <tf> to the final "Avoid" sentence (rainersigwald suggestion)

@KalleOlaviNiemitalo

Copy link
Copy Markdown
Contributor

The proposed text makes me wonder if one could work around the problems by publishing a traversal project (that uses Microsoft.Build.Traversal) rather than a solution. Would that just hit the same problems?

I imagine a traversal project might perhaps be able to choose a supported runtime and target framework for each project individually, by using conditional metadata on the ProjectReference items. But I'm not sure that would work if there are also references between those projects and they don't support the same target frameworks.

Copilot AI requested a review from marcpopMSFT April 9, 2026 18:41
@marcpopMSFT
marcpopMSFT marked this pull request as ready for review April 15, 2026 23:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds internal documentation explaining why dotnet publish on a solution (.sln) is discouraged, and points readers to a safer workflow (build the solution, publish projects).

Changes:

  • Add a new doc describing argument-forwarding issues and output-path conflicts when publishing a solution.
  • Document a recommended publish workflow (build solution, then publish projects per RID/TFM).
  • Link the new doc from the documentation index.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
documentation/general/solution-publish.md New guidance explaining solution publish pitfalls and recommended alternatives
documentation/README.md Adds the new doc to the general docs index

When you run `dotnet publish` with CLI arguments on a solution, those arguments are not correctly forwarded to the individual projects inside the solution. Common examples include:

- **`-r` / `--runtime` (RuntimeIdentifier)** – most library projects don't declare any RIDs, so when a RID flows down to them it changes their build behavior. Those projects will look for restore assets that were produced for that specific RID, but restore was most likely run without a RID, so the assets aren't there. Running `dotnet publish --no-restore` with a RID makes the situation worse: it disables the implicit restore that could otherwise recover from the missing assets.
- **`-f` / `--framework` (TargetFramework)** – when a solution passes a target framework to its projects it bypasses the normal project-to-project target framework negotiation. As a result, library projects that are referenced by multiple app projects may be scheduled for build multiple times with the same TF, potentially running concurrently and writing to the same intermediate output directory at the same time.
@github-actions

Copy link
Copy Markdown
Contributor

Due to lack of recent activity, this PR has been labeled as 'Stale'. It will be closed if no further activity occurs within 7 more days. Any new comment will remove the label.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Rainer Sigwald <[email protected]>
@marcpopMSFT
marcpopMSFT enabled auto-merge July 2, 2026 18:31
@marcpopMSFT
marcpopMSFT merged commit 4ddaa1b into main Jul 2, 2026
11 checks passed
@marcpopMSFT
marcpopMSFT deleted the copilot/add-documentation-on-publishing-solutions branch July 2, 2026 19:27
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 6, 2026
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.

6 participants