Run optional post-emitter.ps1 script after SDK generation#47456
Open
msyyc wants to merge 10 commits into
Open
Conversation
Add support for a hard-coded, optional post-emitter PowerShell script (post-emitter.ps1) located in the generated package folder (sdk/<service>/azure-*). When present, it is executed after code generation so service teams (e.g. Foundry) can run custom post-processing on the generated SDK. Safety/robustness: - Only runs a script located directly inside the package folder (guards against path traversal / symlinks). - Invoked non-interactively (-NonInteractive -NoProfile). - Captures and logs stdout/stderr so output is visible in the pipeline. - Wrapped with a 600s timeout. - Failures are logged but never fail the overall generation. - Gracefully skips when no PowerShell (pwsh) executable is available. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the eng/tools/azure-sdk-tools SDK generation pipeline by adding a post-generation hook: if a post-emitter.ps1 script exists directly in a generated package folder, sdk_generator.py will execute it after codegen/metadata updates and before ApiView/build steps, enabling service-specific post-processing.
Changes:
- Added
run_post_emitter_script()to detect and execute an optionalpost-emitter.ps1in the generated package directory with logging, timeout, and failure isolation. - Wired the new hook into
main()immediately aftersdk_update_metadata(...), ensuring downstream steps see any script-produced changes.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
msyyc
commented
Jun 11, 2026
Contributor
|
@copilot change the |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dargilco
reviewed
Jun 11, 2026
dargilco
requested changes
Jun 11, 2026
Helps debugging when a service team adds the script but does not see it run. Also fix a stale docstring reference to the script name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… filename Avoids the docstring drifting out of sync with the constant (the previous literal was stale). The constant is now the single source of truth for the script name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dargilco
approved these changes
Jun 12, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
for microsoft/typespec#10230
Summary
Adds support for an optional, hard-coded post-emitter PowerShell script that runs after SDK code generation. When a script named
_post_emitter.ps1exists directly inside a generated package folder (sdk/<service>/azure-*), the SDK generation pipeline (sdk_generator.py) executes it. This lets service teams (e.g. Foundry) run custom post-processing on the generated SDK.The leading underscore in
_post_emitter.ps1signals that the script is private to the package.This is intentionally not language-specific in spirit; each language repo owns its own pipeline, so the same one-line hook can be replicated to other language repos once validated for Python.
Behavior
_post_emitter.ps1in the package folder after code generation / metadata update and before ApiView + build, so downstream steps pick up any changes.Safety / robustness
pwsh -NonInteractive -NoProfile -ExecutionPolicy Bypass -File.pwsh/powershell) executable is available, it logs a warning and skips.Testing
Validated locally with a temp package folder containing a
_post_emitter.ps1: script executes, stdout/stderr are logged, and the no-script case is a no-op.