{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Replace fpm with native macOS packaging tools (pkgbuild/productbuild) #26268
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
Merged
Travis Plunk (TravisEz13)
merged 22 commits into
master
from
copilot/update-macos-packaging-tool
Oct 28, 2025
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
42add6e
Initial plan
Copilot ab910f5
Replace fpm with native macOS packaging tools (pkgbuild/productbuild)
Copilot 626e6f9
Fix symlink handling in New-MacOSPackage
Copilot cbd9889
Update documentation to reflect native macOS packaging tools
Copilot 507955f
Add macOS package creation and validation to CI workflow
Copilot f583bad
Combine build and package steps in same task
Copilot 039aa8d
Convert package validation to Pester test
Copilot bf63843
Add -SkipReleaseChecks to Start-PSPackage call
Copilot 5f1dfd9
Use process-pester-results action for test result publishing
Copilot bd2875f
Fix symlink creation in macOS package - recreate instead of copy
Copilot 67cc0af
Fix directory cleanup race condition in macOS package test
Copilot 3894307
Use Pester TestDrive for package expansion directories
Copilot 08d989f
Use FullName instead of DirectoryName in verbose log
Copilot 9dfd4c5
Use Join-Path for constructing payload file path
Copilot abb8f6d
Apply suggestion from @TravisEz13
TravisEz13 77d1387
Update man page path in releasing documentation
TravisEz13 4409398
Refactor to reuse New-MacOsDistributionPackage function
Copilot d1888e5
Use Start-NativeExecution for pkgbuild and productbuild commands
Copilot 41624e0
Merge branch 'master' into copilot/update-macos-packaging-tool
TravisEz13 74c2190
Add Switch-PSNugetConfig to macOS CI and update build guide
Copilot 3b45318
Use Start-NativeExecution for pkgutil and chmod commands
Copilot e874759
Merge branch 'master' into copilot/update-macos-packaging-tool
TravisEz13 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
149 changes: 149 additions & 0 deletions
149
.github/instructions/start-native-execution.instructions.md
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,149 @@ | ||
| --- | ||
| applyTo: | ||
| - "**/*.ps1" | ||
| - "**/*.psm1" | ||
| --- | ||
|
|
||
| # Using Start-NativeExecution for Native Command Execution | ||
|
|
||
| ## Purpose | ||
|
|
||
| `Start-NativeExecution` is the standard function for executing native commands (external executables) in PowerShell scripts within this repository. It provides consistent error handling and better diagnostics when native commands fail. | ||
|
|
||
| ## When to Use | ||
|
|
||
| Use `Start-NativeExecution` whenever you need to: | ||
| - Execute external commands (e.g., `git`, `dotnet`, `pkgbuild`, `productbuild`, `fpm`, `rpmbuild`) | ||
| - Ensure proper exit code checking | ||
| - Get better error messages with caller information | ||
| - Handle verbose output on error | ||
|
|
||
| ## Basic Usage | ||
|
|
||
| ```powershell | ||
| Start-NativeExecution { | ||
| git clone https://github.com/PowerShell/PowerShell.git | ||
| } | ||
| ``` | ||
|
|
||
| ## With Parameters | ||
|
|
||
| Use backticks for line continuation within the script block: | ||
|
|
||
| ```powershell | ||
| Start-NativeExecution { | ||
| pkgbuild --root $pkgRoot ` | ||
| --identifier $pkgIdentifier ` | ||
| --version $Version ` | ||
| --scripts $scriptsDir ` | ||
| $outputPath | ||
| } | ||
| ``` | ||
|
|
||
| ## Common Parameters | ||
|
|
||
| ### -VerboseOutputOnError | ||
|
|
||
| Captures command output and displays it only if the command fails: | ||
|
|
||
| ```powershell | ||
| Start-NativeExecution -VerboseOutputOnError { | ||
| dotnet build --configuration Release | ||
| } | ||
| ``` | ||
|
|
||
| ### -IgnoreExitcode | ||
|
|
||
| Allows the command to fail without throwing an exception: | ||
|
|
||
| ```powershell | ||
| Start-NativeExecution -IgnoreExitcode { | ||
| git diff --exit-code # Returns 1 if differences exist | ||
| } | ||
| ``` | ||
|
|
||
| ## Availability | ||
|
|
||
| The function is defined in `tools/buildCommon/startNativeExecution.ps1` and is available in: | ||
| - `build.psm1` (dot-sourced automatically) | ||
| - `tools/packaging/packaging.psm1` (dot-sourced automatically) | ||
| - Test modules that include `HelpersCommon.psm1` | ||
|
|
||
| To use in other scripts, dot-source the function: | ||
|
|
||
| ```powershell | ||
| . "$PSScriptRoot/../buildCommon/startNativeExecution.ps1" | ||
| ``` | ||
|
|
||
| ## Error Handling | ||
|
|
||
| When a native command fails (non-zero exit code), `Start-NativeExecution`: | ||
| 1. Captures the exit code | ||
| 2. Identifies the calling location (file and line number) | ||
| 3. Throws a descriptive error with full context | ||
|
|
||
| Example error message: | ||
| ``` | ||
| Execution of {git clone ...} by /path/to/script.ps1: line 42 failed with exit code 1 | ||
| ``` | ||
|
|
||
| ## Examples from the Codebase | ||
|
|
||
| ### Git Operations | ||
| ```powershell | ||
| Start-NativeExecution { | ||
| git fetch --tags --quiet upstream | ||
| } | ||
| ``` | ||
|
|
||
| ### Build Operations | ||
| ```powershell | ||
| Start-NativeExecution -VerboseOutputOnError { | ||
| dotnet publish --configuration Release | ||
| } | ||
| ``` | ||
|
|
||
| ### Packaging Operations | ||
| ```powershell | ||
| Start-NativeExecution -VerboseOutputOnError { | ||
| pkgbuild --root $pkgRoot --identifier $pkgId --version $version $outputPath | ||
| } | ||
| ``` | ||
|
|
||
| ### Permission Changes | ||
| ```powershell | ||
| Start-NativeExecution { | ||
| find $staging -type d | xargs chmod 755 | ||
| find $staging -type f | xargs chmod 644 | ||
| } | ||
| ``` | ||
|
|
||
| ## Anti-Patterns | ||
|
|
||
| **Don't do this:** | ||
| ```powershell | ||
| & somecommand $args | ||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "Command failed" | ||
| } | ||
| ``` | ||
|
|
||
| **Do this instead:** | ||
| ```powershell | ||
| Start-NativeExecution { | ||
| somecommand $args | ||
| } | ||
| ``` | ||
|
|
||
| ## Best Practices | ||
|
|
||
| 1. **Always use Start-NativeExecution** for native commands to ensure consistent error handling | ||
| 2. **Use -VerboseOutputOnError** for commands with useful diagnostic output | ||
| 3. **Use backticks for readability** when commands have multiple arguments | ||
| 4. **Don't capture output unnecessarily** - let the function handle it | ||
| 5. **Use -IgnoreExitcode sparingly** - only when non-zero exit codes are expected and acceptable | ||
|
|
||
| ## Related Documentation | ||
|
|
||
| - Source: `tools/buildCommon/startNativeExecution.ps1` | ||
| - Blog post: https://mnaoumov.wordpress.com/2015/01/11/execution-of-external-commands-in-powershell-done-right/ | ||
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
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
Oops, something went wrong.
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.
You can’t perform that action at this time.

Uh oh!
There was an error while loading. Please reload this page.