Repository navigation
docs: explain why publishing a solution is discouraged - #53693
Conversation
|
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. |
There was a problem hiding this comment.
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. |
|
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]>
-r/RuntimeIdentifier bullet with precise RID-restore explanation (marcpopMSFT + rainersigwald + baronfel)-f/TargetFramework bullet (rainersigwald)-f <tf>to the final "Avoid" sentence (rainersigwald suggestion)