You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/commands-implementation-details.md
+28-5Lines changed: 28 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,13 +53,36 @@ If there are any existing changesets the command generates changelogs for every
53
53
changeset publish
54
54
```
55
55
56
-
Creates nuget packages of affected projects and publishes them to the predefined package source. The command:
56
+
Creates NuGet packages of affected projects and publishes them to the predefined package source.
57
57
58
-
1. Gets all modified `.csproj` files from the predefined working directory using `git diff --name-only`.
59
-
1. Creates nuget package using `nuget pack` for every csproj file.
60
-
1. Pushes the created nuget packages to the predefined nuget source using `nuget push`.
58
+
### How it works (current .NET implementation)
61
59
62
-
The package source can be configured via `config.json` file.
60
+
Currently, the `publish` command assumes that the changes made by the `version` command have **already been committed**. The intended flow is:
61
+
62
+
1. Run `changeset version` to bump versions, update changelogs, and delete processed changesets.
63
+
2. Commit the changes produced by the `version` command.
64
+
3. Run `changeset publish` to create and push NuGet packages based on the committed changes.
65
+
66
+
The `publish` command does following:
67
+
68
+
1. Gets all modified `.csproj` files from the predefined source directory by comparing the last two commits `git diff --name-only HEAD~1 HEAD {sourcePath}`
69
+
2. For each changed `.csproj` file, creates a NuGet package using `dotnet pack`.
70
+
3. Pushes the created NuGet packages to the predefined NuGet source using `dotnet nuget push`.
71
+
72
+
The package source can be configured via the `.changeset/config.json` file (see `docs/config-file-options.md`).
73
+
74
+
This approach relies on the fact that the `version` command only performs three types of changes:
75
+
76
+
- Deleting processed changeset files from the `.changeset` folder
77
+
- Modifying or creating `CHANGELOG.md` files
78
+
- Bumping versions in `.csproj` files
79
+
80
+
By looking at the diff between `HEAD~1` and `HEAD`, `publish` can safely identify which projects had their versions bumped and therefore need to be published.
81
+
82
+
### Comparison with original Node.js changesets implementation
83
+
84
+
The original `@changesets/cli` implementation for Node.js works differently. Instead of relying on a Git diff,
85
+
it checks whether a package with the **current version** from `package.json` already exists in the package registry; if it does not, the package is published.
- The `publish` command now compares the last two commits (HEAD~1 and HEAD) instead of comparing the last commit with the working tree to determine which projects were published.
9
+
This change is required because publishing must be done after version bumps and generated files are committed. Since there is no other reliable way to detect whether the version command was run before publish,
10
+
the comparison is based on committed changes in `.csproj` files. This is still error-prone if users make manual changes to `.csproj` files and run `publish` command, but it is a reasonable compromise for now.
0 commit comments