|
| 1 | +# Build Configuration Guide |
| 2 | + |
| 3 | +## Choosing the Right Configuration |
| 4 | + |
| 5 | +### For Testing |
| 6 | + |
| 7 | +**Use: Default (Debug)** |
| 8 | + |
| 9 | +```yaml |
| 10 | +- name: Build for Testing |
| 11 | + shell: pwsh |
| 12 | + run: | |
| 13 | + Import-Module ./tools/ci.psm1 |
| 14 | + Start-PSBuild |
| 15 | +``` |
| 16 | +
|
| 17 | +**Why Debug:** |
| 18 | +- Includes debugging symbols |
| 19 | +- Better error messages |
| 20 | +- Faster build times |
| 21 | +- Suitable for xUnit and Pester tests |
| 22 | +
|
| 23 | +**Do NOT use:** |
| 24 | +- `-Configuration 'Release'` (unnecessary for tests) |
| 25 | +- `-ReleaseTag` (not needed for tests) |
| 26 | +- `-CI` (unless you specifically need Pester module) |
| 27 | + |
| 28 | +### For Release/Packaging |
| 29 | + |
| 30 | +**Use: Release with version tag** |
| 31 | + |
| 32 | +```yaml |
| 33 | +- name: Build for Release |
| 34 | + shell: pwsh |
| 35 | + run: | |
| 36 | + Import-Module ./tools/ci.psm1 |
| 37 | + $releaseTag = Get-ReleaseTag |
| 38 | + Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag |
| 39 | +``` |
| 40 | + |
| 41 | +**Why Release:** |
| 42 | +- Optimized binaries |
| 43 | +- No debug symbols (smaller size) |
| 44 | +- Production-ready |
| 45 | + |
| 46 | +### For Code Coverage |
| 47 | + |
| 48 | +**Use: CodeCoverage configuration** |
| 49 | + |
| 50 | +```yaml |
| 51 | +- name: Build with Coverage |
| 52 | + shell: pwsh |
| 53 | + run: | |
| 54 | + Import-Module ./tools/ci.psm1 |
| 55 | + Start-PSBuild -Configuration 'CodeCoverage' |
| 56 | +``` |
| 57 | + |
| 58 | +## Platform Considerations |
| 59 | + |
| 60 | +### All Platforms |
| 61 | + |
| 62 | +Same commands work across Linux, Windows, and macOS: |
| 63 | + |
| 64 | +```yaml |
| 65 | +strategy: |
| 66 | + matrix: |
| 67 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 68 | +runs-on: ${{ matrix.os }} |
| 69 | +steps: |
| 70 | + - name: Build PowerShell |
| 71 | + shell: pwsh |
| 72 | + run: | |
| 73 | + Import-Module ./tools/ci.psm1 |
| 74 | + Start-PSBuild |
| 75 | +``` |
| 76 | + |
| 77 | +### Output Locations |
| 78 | + |
| 79 | +**Linux/macOS:** |
| 80 | +``` |
| 81 | +src/powershell-unix/bin/Debug/<netversion>/<runtime>/publish/ |
| 82 | +``` |
| 83 | +
|
| 84 | +**Windows:** |
| 85 | +``` |
| 86 | +src/powershell-win-core/bin/Debug/<netversion>/<runtime>/publish/ |
| 87 | +``` |
| 88 | +
|
| 89 | +## Best Practices |
| 90 | +
|
| 91 | +1. Use default configuration for testing |
| 92 | +2. Avoid redundant parameters |
| 93 | +3. Match configuration to purpose |
| 94 | +4. Use `-CI` only when needed |
| 95 | +5. Always specify `-ReleaseTag` for release or packaging builds |
0 commit comments