RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/Copilot instructions/PowerShell/PowerShell

Copilot instructions

.github/instructions/start-native-execution.instructions.md
Copilot instructions

Quality

86/100

Scores the file, not the repository.

Length

434 words

18 headings · 12 code blocks

Repository

55k

— · pushed 0 days ago

Last changed

3 days ago

First indexed 3 days ago.
PowerShell/PowerShell/.github/instructions/start-native-execution.instructions.mdRawGitHub
1---
2applyTo:
3 - "**/*.ps1"
4 - "**/*.psm1"
5---
6 
7# Using Start-NativeExecution for Native Command Execution
8 
9## Purpose
10 
11`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.
12 
13## When to Use
14 
15Use `Start-NativeExecution` whenever you need to:
16- Execute external commands (e.g., `git`, `dotnet`, `pkgbuild`, `productbuild`, `fpm`, `rpmbuild`)
17- Ensure proper exit code checking
18- Get better error messages with caller information
19- Handle verbose output on error
20 
21## Basic Usage
22 
23```powershell
24Start-NativeExecution {
25 git clone https://github.com/PowerShell/PowerShell.git
26}
27```
28 
29## With Parameters
30 
31Use backticks for line continuation within the script block:
32 
33```powershell
34Start-NativeExecution {
35 pkgbuild --root $pkgRoot `
36 --identifier $pkgIdentifier `
37 --version $Version `
38 --scripts $scriptsDir `
39 $outputPath
40}
41```
42 
43## Common Parameters
44 
45### -VerboseOutputOnError
46 
47Captures command output and displays it only if the command fails:
48 
49```powershell
50Start-NativeExecution -VerboseOutputOnError {
51 dotnet build --configuration Release
52}
53```
54 
55### -IgnoreExitcode
56 
57Allows the command to fail without throwing an exception:
58 
59```powershell
60Start-NativeExecution -IgnoreExitcode {
61 git diff --exit-code # Returns 1 if differences exist
62}
63```
64 
65## Availability
66 
67The function is defined in `tools/buildCommon/startNativeExecution.ps1` and is available in:
68- `build.psm1` (dot-sourced automatically)
69- `tools/packaging/packaging.psm1` (dot-sourced automatically)
70- Test modules that include `HelpersCommon.psm1`
71 
72To use in other scripts, dot-source the function:
73 
74```powershell
75. "$PSScriptRoot/../buildCommon/startNativeExecution.ps1"
76```
77 
78## Error Handling
79 
80When a native command fails (non-zero exit code), `Start-NativeExecution`:
811. Captures the exit code
822. Identifies the calling location (file and line number)
833. Throws a descriptive error with full context
84 
85Example error message:
86```
87Execution of {git clone ...} by /path/to/script.ps1: line 42 failed with exit code 1
88```
89 
90## Examples from the Codebase
91 
92### Git Operations
93```powershell
94Start-NativeExecution {
95 git fetch --tags --quiet upstream
96}
97```
98 
99### Build Operations
100```powershell
101Start-NativeExecution -VerboseOutputOnError {
102 dotnet publish --configuration Release
103}
104```
105 
106### Packaging Operations
107```powershell
108Start-NativeExecution -VerboseOutputOnError {
109 pkgbuild --root $pkgRoot --identifier $pkgId --version $version $outputPath
110}
111```
112 
113### Permission Changes
114```powershell
115Start-NativeExecution {
116 find $staging -type d | xargs chmod 755
117 find $staging -type f | xargs chmod 644
118}
119```
120 
121## Anti-Patterns
122 
123**Don't do this:**
124```powershell
125& somecommand $args
126if ($LASTEXITCODE -ne 0) {
127 throw "Command failed"
128}
129```
130 
131**Do this instead:**
132```powershell
133Start-NativeExecution {
134 somecommand $args
135}
136```
137 
138## Best Practices
139 
1401. **Always use Start-NativeExecution** for native commands to ensure consistent error handling
1412. **Use -VerboseOutputOnError** for commands with useful diagnostic output
1423. **Use backticks for readability** when commands have multiple arguments
1434. **Don't capture output unnecessarily** - let the function handle it
1445. **Use -IgnoreExitcode sparingly** - only when non-zero exit codes are expected and acceptable
145 
146## Related Documentation
147 
148- Source: `tools/buildCommon/startNativeExecution.ps1`
149- Blog post: https://mnaoumov.wordpress.com/2015/01/11/execution-of-external-commands-in-powershell-done-right/
150 

Commands it names

  • git clone https://github.com/PowerShell/PowerShell.git
  • dotnet build --configuration Release
  • git diff --exit-code
  • git fetch --tags --quiet upstream
  • dotnet publish --configuration Release
  • git
  • dotnet

Sections

  • Using Start-NativeExecution for Native Command Execution
  • Purpose
  • When to Use
  • Basic Usage
  • With Parameters
  • Common Parameters
  • -VerboseOutputOnError
  • -IgnoreExitcode
  • Availability
  • Error Handling
  • Examples from the Codebase
  • Git Operations
  • Build Operations
  • Packaging Operations
  • Permission Changes
  • Anti-Patterns
  • Best Practices
  • Related Documentation

What it covers

buildcode-stylearchitecturegit-prdocs

Stack — with the evidence

csharp

(1.00)

dotnet

(1.00)

github-actions

(0.60)

Glob targeting

  • **/*.ps1
  • **/*.psm1

Format

Copilot instructions

Two layers: one always-on repo file, plus optional glob-scoped instruction files. Lives under .github/ rather than the repo root, which is the tell that it is aimed at the GitHub platform surface as much as the editor.

What the corpus says about it

Repository

Owner
PowerShell
Language
—
License
—
Archived
no

All configs in this repo

Also in PowerShell/PowerShell

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
PowerShell/PowerShell.github/instructions/code-review-branch-strategy.instructions.md · 55kCopilot instructionscsharpdotnet+1lint-formatstyletypesgit+162/1003 days ago
PowerShell/PowerShell.github/instructions/instruction-file-format.instructions.md · 55kCopilot instructionscsharpdotnet+1buildlint-formatstylearch+376/1003 days ago
PowerShell/PowerShell.github/instructions/pester-set-itresult-pattern.instructions.md · 55kCopilot instructionscsharpdotnet+1setupstylearch62/1003 days ago
PowerShell/PowerShell.github/instructions/powershell-automatic-variables.instructions.md · 55kCopilot instructionscsharpdotnet+1stylearchgitdeployment+169/1003 days ago
PowerShell/PowerShell.github/instructions/pester-test-status-and-working-meaning.instructions.md · 55kCopilot instructionscsharpdotnet+1teststyle54/1003 days ago
PowerShell/PowerShell.github/instructions/build-and-packaging-steps.instructions.md · 55kCopilot instructionscsharpdotnet+1buildagent-behaviour58/1003 days ago
PowerShell/PowerShell.github/instructions/build-checkout-prerequisites.instructions.md · 55kCopilot instructionscsharpdotnet+1setupbuildstylearch+181/1003 days ago
PowerShell/PowerShell.github/instructions/build-configuration-guide.instructions.md · 55kCopilot instructionscsharpdotnet+1buildteststyletesting-strategy+274/1003 days ago
PowerShell/PowerShell.github/instructions/log-grouping-guidelines.instructions.md · 55kCopilot instructionscsharpdotnet+1buildtestdo-not77/1003 days ago
PowerShell/PowerShell.github/instructions/onebranch-condition-syntax.instructions.md · 55kCopilot instructionscsharpdotnet+1buildstylearchdeployment+173/1003 days ago
PowerShell/PowerShell.github/instructions/onebranch-restore-phase-pattern.instructions.md · 55kCopilot instructionscsharpdotnet+1arch54/1003 days ago
PowerShell/PowerShell.github/instructions/onebranch-signing-configuration.instructions.md · 55kCopilot instructionscsharpdotnet+1buildstyledeployment62/1003 days ago
PowerShell/PowerShell.github/instructions/powershell-module-organization.instructions.md · 55kCopilot instructionscsharpdotnet+1buildteststylearch+269/1003 days ago
PowerShell/PowerShell.github/instructions/powershell-parameter-naming.instructions.md · 55kCopilot instructionscsharpdotnet+1styledo-not65/1003 days ago
PowerShell/PowerShell.github/instructions/publishing-pester-result.instructions.md · 55kCopilot instructionscsharpdotnet+1testlint-formatstylearch+369/1003 days ago
PowerShell/PowerShell.github/instructions/script-module-file-format.instructions.md · 55kCopilot instructionscsharpdotnet+1lint-format54/1003 days ago
PowerShell/PowerShell.github/instructions/start-psbuild-basics.instructions.md · 55kCopilot instructionscsharpdotnet+1buildtesting-strategydeploymentagent-behaviour54/1003 days ago
PowerShell/PowerShell.github/instructions/troubleshooting-builds.instructions.md · 55kCopilot instructionscsharpdotnet+1buildgitdeployment54/1003 days ago
Diff against .github/instructions/code-review-branch-strategy.instructions.md Diff against .github/instructions/instruction-file-format.instructions.md Diff against .github/instructions/pester-set-itresult-pattern.instructions.md Diff against .github/instructions/powershell-automatic-variables.instructions.md Diff against .github/instructions/pester-test-status-and-working-meaning.instructions.md Diff against .github/instructions/build-and-packaging-steps.instructions.md Diff against .github/instructions/build-checkout-prerequisites.instructions.md Diff against .github/instructions/build-configuration-guide.instructions.md Diff against .github/instructions/log-grouping-guidelines.instructions.md Diff against .github/instructions/onebranch-condition-syntax.instructions.md Diff against .github/instructions/onebranch-restore-phase-pattern.instructions.md Diff against .github/instructions/onebranch-signing-configuration.instructions.md Diff against .github/instructions/powershell-module-organization.instructions.md Diff against .github/instructions/powershell-parameter-naming.instructions.md Diff against .github/instructions/publishing-pester-result.instructions.md Diff against .github/instructions/script-module-file-format.instructions.md Diff against .github/instructions/start-psbuild-basics.instructions.md Diff against .github/instructions/troubleshooting-builds.instructions.md

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
chihebnabil/lovable-boilerplate.github/instructions/global.instructions.md · 63Copilot instructionstypescriptreact+7buildlint-formatstylearch+4100/1003 days ago
louislam/uptime-kuma.github/copilot-instructions.md · 90kCopilot instructionstypescriptjavascript+10setupbuildtestlint-format+9100/1003 days ago
pytorch/pytorch.github/copilot-instructions.md · 102kCopilot instructionspythonpytorch+4setupbuildteststyle+5100/1003 days ago
dotnet/roslyn.github/instructions/Compiler.instructions.md · 21kCopilot instructionscsharpdotnet+1buildteststylearch+399/1003 days ago
JCodesMore/ai-website-cloner-template.github/copilot-instructions.md · 31kCopilot instructionstypescriptnode+7buildlint-formatstylearch+397/1002 days ago
hiyouga/LlamaFactory.github/copilot-instructions.md · 74kCopilot instructionspythontransformers+4setupbuildtestlint-format+597/1002 days ago
rtk-ai/rtk.github/copilot-instructions.md · 75kCopilot instructionsrustgithub-actionsbuildtestlint-formatstyle+297/1003 days ago
dotnet/roslyn.github/copilot-instructions.md · 21kCopilot instructionscsharpdotnet+1buildteststylearch+397/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack