Skip to content

Allow relative path in -Settings parameter. #908

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

Closed
Benny1007 opened this issue Feb 26, 2018 · 1 comment · Fixed by #909
Closed

Allow relative path in -Settings parameter. #908

Benny1007 opened this issue Feb 26, 2018 · 1 comment · Fixed by #909

Comments

@Benny1007
Copy link

I would like to use a PSScriptAnalyzerSettings.psd1 file in a repository folder, not necessarily at my workspace root. If I include a file in my module folder and try and invoke it, it doesn't take a relative path only the full path to the file. Of course I could be using this incorrectly so feel free to point me in the right direction ;)

Steps to reproduce

I:\MICROSOFT\PowerShell\Modules\BlumeModule> Invoke-ScriptAnalyzer -Path .\private -Setting .\PSScriptAnalyzerSettings.psd1
WARNING: Cannot parse settings. Will abort the invocation.

Expected behavior

I:\MICROSOFT\PowerShell\Modules\BlumeModule> Invoke-ScriptAnalyzer -Path .\private -Setting I:\MICROSOFT\PowerShell\Modules\BlumeModule\PSScriptAnalyzerSettings.psd1

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSUseApprovedVerbs                  Warning      perform-up 1     The cmdlet 'Perform-Update' uses an unapproved verb.
                                                 date.ps1

Actual behavior

WARNING: Cannot parse settings. Will abort the invocation.

Environment data

> $PSVersionTable
Name                           Value                                                                                        BlumeModule\PSScriptAnalyzerSettings.psd1
----                           -----
PSVersion                      5.1.16299.248PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.248CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }

I:\MICROSOFT\PowerShell\Modules\BlumeModule> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.16.11.16.1
@bergmeister
Copy link
Collaborator

bergmeister commented Feb 26, 2018

@Benny1007 Thanks for reporting this. For the moment please use a full path but it should not be too difficult to make it also support relative paths.
In a script you can easily achieve this as follows: $fullPath = Join-Path $PSScriptRoot 'relative\path'
On the command line you can do : Join-Path (Get-Location) 'relative\path'
And if your relative path includes navigation like e.g. ..\ then you might also need to wrap the resulting path in Resolve-Path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants