Skip to content

Publish generator dev versions during RegenPreview so emitter deps are restorable in CI#11280

Draft
jorgerangel-msft with Copilot wants to merge 15 commits into
mainfrom
copilot/consider-publishing-generator-dev-versions
Draft

Publish generator dev versions during RegenPreview so emitter deps are restorable in CI#11280
jorgerangel-msft with Copilot wants to merge 15 commits into
mainfrom
copilot/consider-publishing-generator-dev-versions

Conversation

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

The regen-preview pipeline rewrites the Azure/mgmt *-emitter-package.json artifacts to point at host-only file: .tgz paths, so CI on the resulting azure-sdk-for-net PR always fails to restore those dependencies (example). This adds an opt-in path to publish the locally built generator packages to the registry configured in .npmrc and reference the published version instead.

Changes

  • RegenPreview.psm1
    • Publish-GeneratorPackage: publishes a .tgz to a registry; treats an already-published version as success so re-runs are idempotent.
    • Update-EmitterPackageArtifact: shared helper to rewrite an emitter-package.json + lock file in either file: mode (default) or published-version mode.
    • Update-GeneratorPackage gains -PublishRegistry/-NpmrcPath: pins deps to the published version (not file:) and publishes the packed .tgz.
    • Update-AzureGenerator / Update-MgmtGenerator thread these through and use the shared helper.
  • Submit-AzureSdkForNetPr.ps1: new -PublishGeneratorPackages switch that resolves the registry + authenticated .npmrc and drives publishing through the Azure/mgmt regeneration paths.
  • publish.yml: new opt-in PublishGeneratorPackages pipeline parameter.

With the switch off (default), behavior is unchanged — deps stay pinned via file:. Publishing order (unbranded from the main stage → Azure → mgmt) ensures each package's dependencies are resolvable from the feed; the local RegenPreview.ps1 loop is untouched since it cleans up and never commits.

Result

The emitter artifact references a published version restorable by CI:

// azure-typespec-http-client-csharp-emitter-package.json (published mode)
"dependencies": {
  "@azure-typespec/http-client-csharp": "1.0.0-alpha.20250101.abc"  // was "file:/…/…-*.tgz"
}

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

…e restorable in CI

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Jul 16, 2026
Copilot AI changed the title [WIP] Consider publishing generator dev versions when running RegenPreview Publish generator dev versions during RegenPreview so emitter deps are restorable in CI Jul 16, 2026
Copilot AI requested a review from jorgerangel-msft July 16, 2026 20:14
@pkg-pr-new

pkg-pr-new Bot commented Jul 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@11280

commit: 5881cf2

Comment thread packages/http-client-csharp/eng/pipeline/publish.yml Outdated
…ve opt-in parameter)

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot AI and others added 2 commits July 17, 2026 17:02
…ish to ADO feed only

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot AI and others added 2 commits July 17, 2026 17:27
…h.yml

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Comment thread packages/http-client-csharp/eng/pipeline/publish.yml
…ps1 npm publish

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…only scope

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Comment thread packages/http-client-csharp/eng/pipeline/publish.yml Outdated
Comment thread packages/http-client-csharp/eng/pipeline/publish.yml Outdated
Comment thread packages/http-client-csharp/eng/scripts/Submit-AzureSdkForNetPr.ps1 Outdated
@jorgerangel-msft

Copy link
Copy Markdown
Contributor

@copilot pull latest main and address the merge conflicts

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

This PR restructures the http-client-csharp publish pipeline’s azure-sdk-for-net regeneration flow to support publishing generator npm packages to an ADO feed and pinning regenerated *-emitter-package.json artifacts to restorable versions (instead of host-only file: paths), so downstream azure-sdk-for-net CI can restore emitter dependencies.

Changes:

  • Split Submit-AzureSdkForNetPr.ps1 into discrete Prepare / BuildGenerators / Regenerate phases that share a single on-disk azure-sdk-for-net checkout and generator package folder.
  • Added Get-NextGeneratorVersion + Update-EmitterPackageArtifact helpers in RegenPreview.psm1 to compute next feed versions and rewrite emitter-package artifacts for either local file: or published-version mode.
  • Centralized npm publishing to the ADO feed via a reusable pipeline step template and updated emitter pipeline stages to use it.

Reviewed changes

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

Show a summary per file
File Description
packages/http-client-csharp/eng/scripts/Submit-AzureSdkForNetPr.ps1 Adds phased execution model and wires generator build/version stamping + artifact rewriting into the PR creation flow.
packages/http-client-csharp/eng/scripts/RegenPreview.psm1 Adds helper functions to compute next publish version and to rewrite emitter-package artifacts for file vs published mode.
packages/http-client-csharp/eng/pipeline/publish.yml Updates the pipeline to run Prepare/BuildGenerators/Publish/Regenerate as separate steps with shared state directories.
eng/emitters/pipelines/templates/steps/publish-to-devops-feed.yml Introduces a reusable step template to publish packed *.tgz packages to the DevOps npm feed.
eng/emitters/pipelines/templates/stages/emitter-stages.yml Replaces inline publish script with the new reusable publish template.

Comment on lines +539 to +545
$unbrandedTgz = Get-ChildItem -Path $BuildArtifactsPath -Filter "typespec-http-client-csharp-*.tgz" -Recurse | Select-Object -First 1
if (-not $unbrandedTgz) {
throw "Could not find unbranded emitter .tgz in build artifacts at: $BuildArtifactsPath"
}
$unbrandedPackagePath = $unbrandedTgz.FullName
Write-Host "Using unbranded package from build artifacts: $unbrandedPackagePath"

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.

@copilot fix this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 5521a55. The BuildGenerators phase now copies the unbranded typespec-http-client-csharp-*.tgz into $DebugFolder and uses that staged path for the downstream Azure/mgmt generator steps.

Comment on lines +497 to 501
$azurePackageName = "azure-typespec-http-client-csharp-$azureVer.tgz"
$unbrandedPackageName = "typespec-http-client-csharp-$unbrandedVer.tgz"
$azurePackagePath = Join-Path $DebugFolder $azurePackageName
$unbrandedPackagePath = Join-Path $DebugFolder $unbrandedPackageName

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.

@copilot fix this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 7a791a8. Publish-mode now skips the local Azure/unbranded tgz existence checks, so mgmt regen only validates those staged tgz paths in file-mode.

Comment on lines +91 to +101
$PublishRegistry = $null
$PublishNpmrcPath = $null
if ($RegenerateAzureLibraries -or $RegenerateMgmtLibraries) {
$PublishRegistry = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/"
$resolvedPublishNpmrc = Join-Path $PSScriptRoot "../../.npmrc"
if (Test-Path $resolvedPublishNpmrc) {
$PublishNpmrcPath = (Resolve-Path $resolvedPublishNpmrc).Path
Write-Host "Generator packages will be published to $PublishRegistry using .npmrc at $PublishNpmrcPath"
} else {
Write-Host "Generator packages will be published to $PublishRegistry using ambient npm configuration"
}

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.

@copilot fix this. PublishGeneratorPackages should be on when running in CI mode only

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 7a791a8. Submit-AzureSdkForNetPr.ps1 now has an explicit -PublishGeneratorPackages switch, and publish.yml only passes it from the CI pipeline when Azure or mgmt regeneration is requested, so local regen stays on file: references by default.

Comment on lines +220 to +223
.PARAMETER PublishRegistry
When provided, dependencies are pinned to their published versions (see PublishedDependencyVersions)
instead of a local "file:" path, and the packed .tgz is published to this registry so the resulting
emitter artifacts reference a version that CI can restore.

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.

@copilot fix this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 7a791a8. The PublishRegistry docs now describe stamping the package for the pipeline publish flow instead of claiming the helper publishes it directly.

…able

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…ions

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@copilot pull latest main and address the merge conflicts

Addressed in 831793c. I pulled latest main, resolved the conflicts in publish.yml and Submit-AzureSdkForNetPr.ps1, and kept the newer Build.Reason handling wired through the shared submit arguments.

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot AI and others added 3 commits July 20, 2026 23:13
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp eng

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider Publishing Generator Dev Versions When Running RegenPreview

3 participants