BuildHelpers icon indicating copy to clipboard operation
BuildHelpers copied to clipboard

Get-ProjectName fails when alias `git` exists

Open peetrike opened this issue 3 years ago • 2 comments

When there is defined alias with name git, the Get-ProjectName command (called without parameters) emits following error message:

The variable cannot be validated because the value $null is not a valid value for the GitPath variable.
At C:\Program Files\WindowsPowerShell\Modules\BuildHelpers\2.0.16\Public\Get-ProjectName.ps1:57 char:9
+         $GitPath = (Get-Command $GitPath -ErrorAction SilentlyContinu ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The command itself works despite the error above.

The error could be avoided when $GitPath variable contains string git.exe or when the get-command has parameter -CommandType Application added at: https://github.com/RamblingCookieMonster/BuildHelpers/blob/master/BuildHelpers/Public/Get-ProjectName.ps1#L57

peetrike avatar Oct 24 '22 14:10 peetrike

Also the next line could have parameter -CommandType Application added: https://github.com/RamblingCookieMonster/BuildHelpers/blob/master/BuildHelpers/Public/Get-ProjectName.ps1#L47

peetrike avatar Oct 24 '22 14:10 peetrike

The same problematic pattern is also in Invoke-Git command: https://github.com/RamblingCookieMonster/BuildHelpers/blob/master/BuildHelpers/Public/Invoke-Git.ps1#L87

peetrike avatar Oct 24 '22 15:10 peetrike