Skip to content

Commit

Permalink
Fix NuGet initialization in Windows PS
Browse files Browse the repository at this point in the history
  • Loading branch information
metablaster committed Jun 18, 2023
1 parent 3e68acf commit 875f27f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Modules/Ruleset.Initialize/Public/Initialize-Provider.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,11 @@ function Initialize-Provider
# It may also be the case if a user denied registering a package source.
if (!$FoundPackageSource -or ($FoundPackageSource.ProviderName -notin (Get-PackageSource).ProviderName))
{
Write-Warning -Message "[$($MyInvocation.InvocationName)] Not using '$($FoundPackageSource.ProviderName)' provider to install package, package source not registered"
# Else warning was diplayed by Get-PackageSource
if ($FoundPackageSource)
{
Write-Warning -Message "[$($MyInvocation.InvocationName)] Not using '$($FoundPackageSource.ProviderName)' provider to install package, package source not registered"
}

# TODO: This scenario needs testing, it currently works for NuGet in Windows PowerShell
return $null -ne (Get-PackageProvider -Name $ProviderName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function Uninstall-DuplicateModule
}
catch
{
Write-Warning -Message "[$($MyInvocation.InvocationName)] Please close down all other PowerShell sessions including VSCode, then try again"
Write-Warning -Message "[$($MyInvocation.InvocationName)] Please close down all PowerShell sessions including VSCode, then try again in fresh console"

Write-Error -Category ResourceBusy -TargetObject $LoadedModule `
-Message "Module '$ModuleName' could not be removed from current PS session which is required for uninstallation because: $($_.Exception.Message)"
Expand Down Expand Up @@ -244,7 +244,7 @@ function Uninstall-DuplicateModule
}
else
{
Write-Warning -Message "[$($MyInvocation.InvocationName)] please close down all other PowerShell sessions including VSCode, then try again"
Write-Warning -Message "[$($MyInvocation.InvocationName)] please close down other PowerShell sessions including VSCode, then try again in fresh console"
}

Write-Error -Category OperationStopped -TargetObject $ModuleRoot `
Expand Down
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Here is a list of changes for each of the releases.
- `Get-SystemSoftware` renamed to `Get-SystemProgram`
- `Get-UserSoftware` renamed to `Get-UserProgram`
- `Get-SystemProgram` Improved program search
- `Uninstall-DuplicateModule` Improved to show reason for failure and how to fix
- `Initialize-Provider` Was failing in Windows PS on Windows 11, fixed

- Scripts

Expand Down

0 comments on commit 875f27f

Please sign in to comment.