Skip to content

Commit d0fa872

Browse files
committed
Fix PSScriptAnalyzer settings path default to ./PSScriptAnalyzerSettings.psd1
The default SettingsPath is not $null — PowerShellBuild automatically looks for PSScriptAnalyzerSettings.psd1 in the project root. Updated the configuration reference default value and description, the real-world example to rely on the convention instead of an explicit override, and the example filename from .psscriptanalyzer.psd1 to PSScriptAnalyzerSettings.psd1. https://claude.ai/code/session_01TU1s3wRx7eGZhMJJXvY5Kz
1 parent 4610369 commit d0fa872

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

docs/powershellbuild/configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ properties {
8383
|---------|---------|-------------|
8484
| `Test.ScriptAnalysis.Enabled` | `$true` | Run PSScriptAnalyzer |
8585
| `Test.ScriptAnalysis.FailBuildOnSeverityLevel` | `'Error'` | Build fails on violations at or above this severity (`'Error'`, `'Warning'`, `'Information'`) |
86-
| `Test.ScriptAnalysis.SettingsPath` | `$null` | Path to a PSScriptAnalyzer settings file |
86+
| `Test.ScriptAnalysis.SettingsPath` | `./PSScriptAnalyzerSettings.psd1` | Path to a PSScriptAnalyzer settings file. Defaults to `PSScriptAnalyzerSettings.psd1` in the project root — if the file exists it is used automatically |
8787

8888
```powershell
8989
properties {
9090
# Fail on warnings too
9191
$PSBPreference.Test.ScriptAnalysis.FailBuildOnSeverityLevel = 'Warning'
9292
93-
# Use a custom ruleset
94-
$PSBPreference.Test.ScriptAnalysis.SettingsPath = "$PSScriptRoot/.psscriptanalyzer.psd1"
93+
# Override the default settings file location
94+
$PSBPreference.Test.ScriptAnalysis.SettingsPath = "$PSScriptRoot/build/analyzersettings.psd1"
9595
}
9696
```
9797

docs/powershellbuild/real-world-example.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ MyModule/
2828
│ └── build.yml
2929
├── psakeFile.ps1
3030
├── build.ps1
31+
├── PSScriptAnalyzerSettings.psd1 # Auto-detected by PowerShellBuild
3132
└── requirements.psd1
3233
```
3334

@@ -120,9 +121,9 @@ properties {
120121
$PSBPreference.Test.ImportModule = $true
121122
122123
# Test — PSScriptAnalyzer
124+
# SettingsPath defaults to ./PSScriptAnalyzerSettings.psd1 in the project root
123125
$PSBPreference.Test.ScriptAnalysis.Enabled = $true
124126
$PSBPreference.Test.ScriptAnalysis.FailBuildOnSeverityLevel = 'Error'
125-
$PSBPreference.Test.ScriptAnalysis.SettingsPath = "$PSScriptRoot/.psscriptanalyzer.psd1"
126127
127128
# Test — Code Coverage
128129
$PSBPreference.Test.CodeCoverage.Enabled = $true
@@ -196,11 +197,11 @@ task Deploy -depends BumpVersion, ValidateReadme, Publish {
196197
}
197198
```
198199

199-
## `.psscriptanalyzer.psd1`
200+
## `PSScriptAnalyzerSettings.psd1`
200201

201-
A custom PSScriptAnalyzer settings file referenced above:
202+
PowerShellBuild looks for `PSScriptAnalyzerSettings.psd1` in the project root by default. Place your custom rules here and they will be picked up automatically — no need to set `SettingsPath`.
202203

203-
```powershell title=".psscriptanalyzer.psd1"
204+
```powershell title="PSScriptAnalyzerSettings.psd1"
204205
@{
205206
ExcludeRules = @(
206207
'PSAvoidUsingWriteHost' # Write-Host is acceptable in build scripts

0 commit comments

Comments
 (0)