-
Notifications
You must be signed in to change notification settings - Fork 5k
RunApiDiff script and documentation improvements #10241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jeffhandley
wants to merge
49
commits into
main
Choose a base branch
from
jeffhandley/apidiff-improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
ef9876a
Use flat2 package lookup before attempting a search
jeffhandley b39b267
Infer CoreRepo parameter from git repo root
jeffhandley 33251f0
Resolve CoreRepo and TmpFolder to absolute paths
jeffhandley d66ecc7
Default PreviousNuGetFeed to nuget.org
jeffhandley 5b88e92
Rename PreviewOrRC to ReleaseKind and make PreviewNumberVersion optio…
jeffhandley 929e7d4
Rename DotNetVersion to MajorMinor and PreviewNumberVersion to Previe…
jeffhandley 99c4c5a
Make TmpFolder optional with auto-created temp directory
jeffhandley e86bc82
Auto-discover current version from NuGet feed
jeffhandley 0da47ea
Auto-discover previous version from NuGet feed
jeffhandley 867a104
Accept CurrentNuGetFeed as a positional parameter
jeffhandley ab1cd95
Rewrite RunApiDiff.md with full parameter documentation
jeffhandley b0c4ecf
Clarify ApiDiff tool install instructions
jeffhandley 7e558bf
Clean up docs and examples
jeffhandley 9a67bf2
Default CurrentNuGetFeed to nuget.org
jeffhandley 2eea768
Combine ReleaseKind and PreviewRCNumber into PrereleaseLabel
jeffhandley 236b77f
Rename PackageVersion to Version and extract MajorMinor/PrereleaseLab…
jeffhandley 21b2271
Deduplicate version-parsing logic
jeffhandley 30795b9
Move ParsePrereleaseLabel to the Functions section
jeffhandley 9e7ce18
Remove dead RebuildIfExeNotFound function
jeffhandley 349f44d
Remove RunCommand wrapper and use direct invocation
jeffhandley 76bd53a
Pass all values as explicit named parameters to ProcessSdk
jeffhandley ddfcdc7
Fix inconsistent casing of \ to \
jeffhandley c23e220
Remove stale comment and extra blank line
jeffhandley 6e3fb8f
Fix GetReleaseKindFolderName missing dot in GA patch path
jeffhandley 3e74ddf
Convert bool parameters to switch parameters
jeffhandley 21cf78c
Simplify DownloadPackage by making search params optional
jeffhandley d15caa3
Fix Write-Color to use Write-Host instead of Write-Output
jeffhandley 4a7601c
Use Write-Color consistently instead of Write-Host
jeffhandley ad3e0ef
Fix MajorMinor ValidatePattern to properly anchor
jeffhandley cd5a137
Simplify redundant guard in DownloadPackage search term
jeffhandley deee7ef
Reuse auth headers in DownloadPackage
jeffhandley e15e904
Use flat2 base URL from service index for downloads
jeffhandley 78c8f34
Pass previewFolderPath as explicit parameter to ProcessSdk
jeffhandley 28ed338
Use named parameters for RunApiDiff call in ProcessSdk
jeffhandley cfeb131
Replace repetitive ProcessSdk calls with a loop
jeffhandley 5210998
Make CreateReadme only list SDKs that were actually processed
jeffhandley 3df7ce1
Resolve exclude file paths relative to script directory
jeffhandley 04aec1c
Final cleanup: deduplicate scriptDir, pass TmpFolder explicitly, fix …
jeffhandley c72e80d
Final docs cleanup
jeffhandley a87eb7f
Default CurrentNuGetFeed to dnceng transport feed based on major version
jeffhandley 585eb0f
Infer current/previous versions from existing api-diff folders
jeffhandley 068cb25
Add Copilot skill for API diff generation
jeffhandley 51da438
Apply review feedback. Remove support for azdo feeds requiring auth.
jeffhandley b1ac061
Apply suggestions from code review
jeffhandley d637dcf
Simplify api-diff skill to focus on intent mapping and script execution
jeffhandley 957732c
Default PreviousNuGetFeed to version-appropriate dnceng feed
jeffhandley 070634b
Support per-framework version discovery for pre-.NET 10 versions
jeffhandley 2dfb6b9
Discover next version by probing feed instead of hardcoded progression
jeffhandley 4c895cf
Simplify api-diff skill to single SKILL.md
jeffhandley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| --- | ||
| name: api-diff | ||
| description: Generate an API comparison report between two .NET versions using the RunApiDiff.ps1 script. Invoke when the user asks to run, create, or generate an API diff. | ||
| disable-model-invocation: true | ||
| --- | ||
|
|
||
| # API Diff Generation | ||
|
|
||
| Map the user's request to parameters for `release-notes/RunApiDiff.ps1` and run it. See [release-notes/RunApiDiff.md](../../../release-notes/RunApiDiff.md) for the full parameter reference. | ||
|
|
||
| When no versions are mentioned, run with no parameters — the script auto-infers versions. | ||
|
|
||
| ## Mapping natural language to parameters | ||
|
|
||
| | User says | Parameters | | ||
| |---|---| | ||
| | "generate the next API diff" | *(none)* | | ||
| | ".NET 10 GA vs .NET 11 Preview 1" | `-PreviousMajorMinor 10.0 -CurrentMajorMinor 11.0 -CurrentPrereleaseLabel preview.1` | | ||
| | "net9.0-preview6 to net10.0-preview5" | `-PreviousMajorMinor 9.0 -PreviousPrereleaseLabel preview.6 -CurrentMajorMinor 10.0 -CurrentPrereleaseLabel preview.5` | | ||
| | ".NET 10 RC 2 vs .NET 10 GA" | `-PreviousMajorMinor 10.0 -PreviousPrereleaseLabel rc.2 -CurrentMajorMinor 10.0` | | ||
| | "10.0.0-preview.7.25380.108 to 10.0.0-rc.1.25451.107" | `-PreviousVersion "10.0.0-preview.7.25380.108" -CurrentVersion "10.0.0-rc.1.25451.107"` | | ||
|
|
||
| - **GA** or no qualifier → omit the PrereleaseLabel parameter | ||
| - **Preview N** / **previewN** → `-PrereleaseLabel preview.N` | ||
| - **RC N** / **rcN** → `-PrereleaseLabel rc.N` | ||
| - **netX.Y-previewN** (TFM format) → `-MajorMinor X.Y -PrereleaseLabel preview.N` | ||
| - Full NuGet version strings → use `-PreviousVersion` / `-CurrentVersion` directly | ||
| - The "previous" version is always the older version; "current" is the newer one | ||
|
|
||
| ## Running the script | ||
|
|
||
| ```powershell | ||
| .\release-notes\RunApiDiff.ps1 [mapped parameters] | ||
| ``` | ||
|
|
||
| Set an initial wait of at least 300 seconds — the script takes several minutes. Use `read_powershell` to poll for completion. The script does not print a final "done" message; it exits after generating a README.md in the output folder. After completion, summarize the results: how many diff files were generated and where. | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,87 @@ | ||
| # RunApiDiff Script | ||
|
|
||
| The [`RunApiDiff.ps1`](./RunApiDiff.ps1) script can automatically generate an API comparison report for two specified .NET previews, in the format expected for publishing in the dotnet/core repo. | ||
| The [`RunApiDiff.ps1`](./RunApiDiff.ps1) script automatically generates an API comparison report between two .NET versions, in the format expected for publishing in the dotnet/core repo. | ||
|
|
||
| ## Instructions | ||
| ## Prerequisites | ||
|
|
||
| - PowerShell 7.0 or later | ||
| - The [Microsoft.DotNet.ApiDiff.Tool](https://www.nuget.org/packages/Microsoft.DotNet.ApiDiff.Tool). Install from the transport feed matching the version you're comparing, or use `-InstallApiDiff $true` to have the script install it automatically: | ||
|
|
||
| 1. Clone the dotnet/core repo. Let's assume you clone it into `D:\core`. | ||
| 2. Create a temporary directory. Let's assume you create it in `D:\tmp`. | ||
| 3. Install or update your copy of the APIDiff tool (use the latest transport feed): | ||
| ``` | ||
| dotnet tool install --global Microsoft.DotNet.ApiDiff.Tool --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10-transport/nuget/v3/index.json --prerelease | ||
| dotnet tool install --global Microsoft.DotNet.ApiDiff.Tool --prerelease | ||
| ``` | ||
| 4. Run the command. Execution example: | ||
|
|
||
| ## Quick Start | ||
|
|
||
| When run with no arguments, the script infers the next version to diff by scanning existing `api-diff` folders in the repository. For example, if the latest api-diff is for .NET 10 GA, it will automatically generate a diff for .NET 11 Preview 1. | ||
|
|
||
| ```powershell | ||
| .\RunApiDiff.ps1 | ||
| ``` | ||
|
|
||
| ## Parameters | ||
|
|
||
| ### Version Parameters | ||
|
|
||
| By default the script assumes a diff will be produced for the next preview. When no version information is provided, the script scans existing `api-diff` folders in the repository to find the latest version and infers the next one in the progression (preview.1 → preview.2 → ... → preview.7 → rc.1 → rc.2 → GA → next major preview.1). When `PreviousVersion` or `CurrentVersion` is provided, the `MajorMinor` and `PrereleaseLabel` values are extracted from it automatically. | ||
|
|
||
| | Parameter | Description | Default | | ||
| |---|---|---| | ||
| | `PreviousVersion` | Exact package version for the "before" comparison (e.g., `10.0.0-preview.7.25380.108`). MajorMinor and PrereleaseLabel are extracted automatically. | *(empty — inferred or searched)* | | ||
| | `CurrentVersion` | Exact package version for the "after" comparison (e.g., `10.0.0-rc.1.25451.107`). MajorMinor and PrereleaseLabel are extracted automatically. | *(empty — inferred or searched)* | | ||
| | `PreviousMajorMinor` | The "before" .NET major.minor version (e.g., `10.0`) | Inferred from api-diffs, extracted from `PreviousVersion`, or discovered from `PreviousNuGetFeed` | | ||
| | `PreviousPrereleaseLabel` | Prerelease label for the "before" version (e.g., `preview.7`, `rc.1`). Omit for GA. | Inferred from api-diffs, extracted from `PreviousVersion`, or discovered from `PreviousNuGetFeed` | | ||
| | `CurrentMajorMinor` | The "after" .NET major.minor version (e.g., `10.0`) | Inferred from api-diffs, extracted from `CurrentVersion`, or discovered from `CurrentNuGetFeed` | | ||
| | `CurrentPrereleaseLabel` | Prerelease label for the "after" version (e.g., `preview.7`, `rc.1`). Omit for GA. | Inferred from api-diffs, extracted from `CurrentVersion`, or discovered from `CurrentNuGetFeed` | | ||
|
|
||
| ### Feed Parameters | ||
|
|
||
| | Parameter | Description | Default | | ||
| |---|---|---| | ||
| | `CurrentNuGetFeed` | NuGet feed URL for downloading "after" packages | Constructed from `CurrentMajorMinor`: `https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet{MAJOR}/nuget/v3/index.json` | | ||
| | `PreviousNuGetFeed` | NuGet feed URL for downloading "before" packages | Constructed from `PreviousMajorMinor`: `https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet{MAJOR}/nuget/v3/index.json` | | ||
|
|
||
| ### Path Parameters | ||
|
|
||
| | Parameter | Description | Default | | ||
| |---|---|---| | ||
| | `CoreRepo` | Path to your local clone of the dotnet/core repo | Git repo root relative to the script | | ||
| | `TmpFolder` | Working directory for downloaded and extracted packages | Auto-created temp directory | | ||
| | `AttributesToExcludeFilePath` | Path to attributes exclusion file | `ApiDiffAttributesToExclude.txt` (same folder as script) | | ||
| | `AssembliesToExcludeFilePath` | Path to assemblies exclusion file | `ApiDiffAssembliesToExclude.txt` (same folder as script) | | ||
|
|
||
| ### Switches | ||
|
|
||
| | Parameter | Description | | ||
| |---|---| | ||
| | `ExcludeNetCore` | Skip the Microsoft.NETCore.App comparison | | ||
| | `ExcludeAspNetCore` | Skip the Microsoft.AspNetCore.App comparison | | ||
| | `ExcludeWindowsDesktop` | Skip the Microsoft.WindowsDesktop.App comparison | | ||
| | `InstallApiDiff` | Install or update the ApiDiff tool before running | | ||
|
|
||
| ## Examples | ||
|
|
||
| ```powershell | ||
| # Infer the previous version from the most recent existing api-diff | ||
| # and infer the the current version to be the next version after it | ||
| .\RunApiDiff.ps1 | ||
|
|
||
| # Specify only the current version; previous is inferred from existing api-diffs | ||
| .\RunApiDiff.ps1 -CurrentMajorMinor 11.0 -CurrentPrereleaseLabel preview.2 | ||
|
|
||
| # Specify both versions explicitly | ||
| .\RunApiDiff.ps1 ` | ||
| -PreviousMajorMinor 10.0 -PreviousPrereleaseLabel preview.7 ` | ||
| -CurrentMajorMinor 10.0 -CurrentPrereleaseLabel rc.1 | ||
|
|
||
| # Use exact NuGet package versions (MajorMinor and PrereleaseLabel are extracted automatically) | ||
| .\RunApiDiff.ps1 ` | ||
| -PreviousVersion "10.0.0-preview.7.25380.108" ` | ||
| -CurrentVersion "10.0.0-rc.1.25451.107" | ||
|
|
||
| # Use a custom feed for the current version's packages | ||
| .\RunApiDiff.ps1 ` | ||
| -PreviousDotNetVersion 10.0 ` | ||
| -PreviousPreviewOrRC preview ` | ||
| -PreviousPreviewNumberVersion 1 ` | ||
| -CurrentDotNetVersion 10.0 ` | ||
| -CurrentPreviewOrRC preview ` | ||
| -CurrentPreviewNumberVersion 2 ` | ||
| -CoreRepo D:\core\ ` | ||
| -TmpFolder D:\tmp\ | ||
| -CurrentNuGetFeed "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet11/nuget/v3/index.json" | ||
| ``` | ||
|
|
||
| Example of what this script generates: [API diff between .NET 10.0 Preview1 and .NET 10 Preview2](https://github.com/dotnet/core/pull/9771) | ||
| Example of what this script generates: [API diff between .NET 10 GA and .NET 11 Preview 1 (dotnet/core#10240)](https://github.com/dotnet/core/pull/10240/changes) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.