Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions src/Modules/Shared/PowerShellGet/PSModule.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ $script:NuGetProviderName = "NuGet"
$script:NuGetProviderVersion = [Version]'2.8.5.201'

$script:SupportsPSModulesFeatureName="supports-powershell-modules"
$script:FastPackRefHastable = @{}
$script:FastPackRefHashtable = @{}
$script:NuGetBinaryProgramDataPath=if(IsWindows) {"$env:ProgramFiles\PackageManagement\ProviderAssemblies"}
$script:NuGetBinaryLocalAppDataPath=if(IsWindows) {"$env:LOCALAPPDATA\PackageManagement\ProviderAssemblies"}
# go fwlink for 'https://nuget.org/nuget.exe'
Expand Down Expand Up @@ -3313,12 +3313,12 @@ function Install-Script
if(-not (Test-RunningAsElevated) -and ($Scope -ne "CurrentUser"))
{
# Throw an error when Install-Script is used as a non-admin user and '-Scope CurrentUser' is not specified
$AdminPreviligeErrorMessage = $LocalizedData.InstallScriptNeedsCurrentUserScopeParameterForNonAdminUser -f @($script:ProgramFilesScriptsPath, $script:MyDocumentsScriptsPath)
$AdminPreviligeErrorId = 'InstallScriptNeedsCurrentUserScopeParameterForNonAdminUser'
$AdminPrivilegeErrorMessage = $LocalizedData.InstallScriptNeedsCurrentUserScopeParameterForNonAdminUser -f @($script:ProgramFilesScriptsPath, $script:MyDocumentsScriptsPath)
$AdminPrivilegeErrorId = 'InstallScriptNeedsCurrentUserScopeParameterForNonAdminUser'

ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $AdminPreviligeErrorMessage `
-ErrorId $AdminPreviligeErrorId `
-ExceptionMessage $AdminPrivilegeErrorMessage `
-ErrorId $AdminPrivilegeErrorId `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidArgument
}
Expand Down Expand Up @@ -3975,17 +3975,17 @@ function Register-PSRepository
{
if (Get-Variable -Name SourceLocation -ErrorAction SilentlyContinue)
{
Set-Variable -Name selctedProviderName -value $null -Scope 1
Set-Variable -Name selectedProviderName -value $null -Scope 1

if(Get-Variable -Name PackageManagementProvider -ErrorAction SilentlyContinue)
{
$selctedProviderName = $PackageManagementProvider
$null = Get-DynamicParameters -Location $SourceLocation -PackageManagementProvider ([REF]$selctedProviderName)
$selectedProviderName = $PackageManagementProvider
$null = Get-DynamicParameters -Location $SourceLocation -PackageManagementProvider ([REF]$selectedProviderName)
}
else
{
$dynamicParameters = Get-DynamicParameters -Location $SourceLocation -PackageManagementProvider ([REF]$selctedProviderName)
Set-Variable -Name PackageManagementProvider -Value $selctedProviderName -Scope 1
$dynamicParameters = Get-DynamicParameters -Location $SourceLocation -PackageManagementProvider ([REF]$selectedProviderName)
Set-Variable -Name PackageManagementProvider -Value $selectedProviderName -Scope 1
$null = $dynamicParameters
}
}
Expand Down Expand Up @@ -4067,9 +4067,9 @@ function Register-PSRepository
{
$providerName = $PackageManagementProvider
}
elseif($selctedProviderName)
elseif($selectedProviderName)
{
$providerName = $selctedProviderName
$providerName = $selectedProviderName
}
else
{
Expand Down Expand Up @@ -4536,16 +4536,16 @@ function Test-ScriptFileInfo

$notSupportedOnNanoErrorIds = @('WorkflowNotSupportedInPowerShellCore',
'ConfigurationNotSupportedInPowerShellCore')
$errosAfterSkippingOneCoreErrors = $errors | Microsoft.PowerShell.Core\Where-Object { $notSupportedOnNanoErrorIds -notcontains $_.ErrorId}
$errorsAfterSkippingOneCoreErrors = $errors | Microsoft.PowerShell.Core\Where-Object { $notSupportedOnNanoErrorIds -notcontains $_.ErrorId}

if($errosAfterSkippingOneCoreErrors)
if($errorsAfterSkippingOneCoreErrors)
{
$errorMessage = ($LocalizedData.ScriptParseError -f $scriptFilePath)
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $errorMessage `
-ErrorId "ScriptParseError" `
-CallerPSCmdlet $PSCmdlet `
-ExceptionObject $errosAfterSkippingOneCoreErrors `
-ExceptionObject $errorsAfterSkippingOneCoreErrors `
-ErrorCategory InvalidArgument
return
}
Expand Down Expand Up @@ -10053,7 +10053,7 @@ function Find-Package
-Type $artifactType `
-request $request

$script:FastPackRefHastable[$fastPackageReference] = $pkg
$script:FastPackRefHashtable[$fastPackageReference] = $pkg

Write-Output -InputObject $sid
}
Expand Down Expand Up @@ -10147,22 +10147,22 @@ function Install-PackageUtility
$packageName = $parts[1]
$version = $parts[2]
$sourceLocation= $parts[3]
$artfactType = $parts[4]
$artifactType = $parts[4]

# The default destination location for Modules and Scripts is ProgramFiles path
$scriptDestination = $script:ProgramFilesScriptsPath
$moduleDestination = $script:programFilesModulesPath
$Scope = 'AllUsers'

if($artfactType -eq $script:PSArtifactTypeScript)
if($artifactType -eq $script:PSArtifactTypeScript)
{
$AdminPreviligeErrorMessage = $LocalizedData.InstallScriptNeedsCurrentUserScopeParameterForNonAdminUser -f @($script:ProgramFilesScriptsPath, $script:MyDocumentsScriptsPath)
$AdminPreviligeErrorId = 'InstallScriptNeedsCurrentUserScopeParameterForNonAdminUser'
$AdminPrivilegeErrorMessage = $LocalizedData.InstallScriptNeedsCurrentUserScopeParameterForNonAdminUser -f @($script:ProgramFilesScriptsPath, $script:MyDocumentsScriptsPath)
$AdminPrivilegeErrorId = 'InstallScriptNeedsCurrentUserScopeParameterForNonAdminUser'
}
else
{
$AdminPreviligeErrorMessage = $LocalizedData.InstallModuleNeedsCurrentUserScopeParameterForNonAdminUser -f @($script:programFilesModulesPath, $script:MyDocumentsModulesPath)
$AdminPreviligeErrorId = 'InstallModuleNeedsCurrentUserScopeParameterForNonAdminUser'
$AdminPrivilegeErrorMessage = $LocalizedData.InstallModuleNeedsCurrentUserScopeParameterForNonAdminUser -f @($script:programFilesModulesPath, $script:MyDocumentsModulesPath)
$AdminPrivilegeErrorId = 'InstallModuleNeedsCurrentUserScopeParameterForNonAdminUser'
}

$installUpdate = $false
Expand Down Expand Up @@ -10195,8 +10195,8 @@ function Install-PackageUtility
{
# Throw an error when Install-Module/Script is used as a non-admin user and '-Scope CurrentUser' is not specified
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $AdminPreviligeErrorMessage `
-ErrorId $AdminPreviligeErrorId `
-ExceptionMessage $AdminPrivilegeErrorMessage `
-ErrorId $AdminPrivilegeErrorId `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidArgument
}
Expand All @@ -10214,8 +10214,8 @@ function Install-PackageUtility
elseif(-not (Test-RunningAsElevated))
{
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $AdminPreviligeErrorMessage `
-ErrorId $AdminPreviligeErrorId `
-ExceptionMessage $AdminPrivilegeErrorMessage `
-ErrorId $AdminPrivilegeErrorId `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidArgument
}
Expand Down Expand Up @@ -10332,7 +10332,7 @@ function Install-PackageUtility
}
}

if($Scope -and ($artfactType -eq $script:PSArtifactTypeScript) -and (-not $installUpdate))
if($Scope -and ($artifactType -eq $script:PSArtifactTypeScript) -and (-not $installUpdate))
{
ValidateAndSet-PATHVariableIfUserAccepts -Scope $Scope `
-ScopePath $scriptDestination `
Expand All @@ -10341,7 +10341,7 @@ function Install-PackageUtility
-Force:$Force
}

if($artfactType -eq $script:PSArtifactTypeModule)
if($artifactType -eq $script:PSArtifactTypeModule)
{
$message = $LocalizedData.ModuleDestination -f @($moduleDestination)
}
Expand All @@ -10352,9 +10352,9 @@ function Install-PackageUtility
Write-Verbose $message
}

Write-Debug "ArtfactType is $artfactType"
Write-Debug "ArtifactType is $artifactType"

if($artfactType -eq $script:PSArtifactTypeModule)
if($artifactType -eq $script:PSArtifactTypeModule)
{
# Test if module is already installed
$InstalledModuleInfo = if(-not $IsSavePackage){ Test-ModuleInstalled -Name $packageName -RequiredVersion $RequiredVersion }
Expand Down Expand Up @@ -10415,7 +10415,7 @@ function Install-PackageUtility
}
}

if($artfactType -eq $script:PSArtifactTypeScript)
if($artifactType -eq $script:PSArtifactTypeScript)
{
# Test if script is already installed
$InstalledScriptInfo = if(-not $IsSavePackage){ Test-ScriptInstalled -Name $packageName }
Expand Down Expand Up @@ -10495,7 +10495,7 @@ function Install-PackageUtility
Write-Verbose ($LocalizedData.SpecifiedLocationAndOGP -f ($provider.ProviderName, $providerName))

$InstalledItemsList = $null
$pkg = $script:FastPackRefHastable[$fastPackageReference]
$pkg = $script:FastPackRefHashtable[$fastPackageReference]

# If an item has dependencies, prepare the list of installed items and
# pass it to the NuGet provider to not download the already installed items.
Expand All @@ -10506,7 +10506,7 @@ function Install-PackageUtility
$InstalledItemsList = Microsoft.PowerShell.Core\Get-Module -ListAvailable |
Microsoft.PowerShell.Core\ForEach-Object {"$($_.Name)!#!$($_.Version)".ToLower()}

if($artfactType -eq $script:PSArtifactTypeScript)
if($artifactType -eq $script:PSArtifactTypeScript)
{
$InstalledItemsList += $script:PSGetInstalledScripts.GetEnumerator() |
Microsoft.PowerShell.Core\ForEach-Object {
Expand Down Expand Up @@ -10534,7 +10534,7 @@ function Install-PackageUtility

$newRequest = $request.CloneRequest( $ProviderOptions, @($SourceLocation), $request.Credential )

if($artfactType -eq $script:PSArtifactTypeModule)
if($artifactType -eq $script:PSArtifactTypeModule)
{
$message = $LocalizedData.DownloadingModuleFromGallery -f ($packageName, $version, $sourceLocation)
}
Expand All @@ -10544,7 +10544,7 @@ function Install-PackageUtility
}
Write-Verbose $message

$installedPkgs = $provider.InstallPackage($script:FastPackRefHastable[$fastPackageReference], $newRequest)
$installedPkgs = $provider.InstallPackage($script:FastPackRefHashtable[$fastPackageReference], $newRequest)

foreach($pkg in $installedPkgs)
{
Expand Down Expand Up @@ -10957,7 +10957,7 @@ function Uninstall-Package
$packageName = $parts[1]
$version = $parts[2]
$sourceLocation= $parts[3]
$artfactType = $parts[4]
$artifactType = $parts[4]

if($request.IsCanceled)
{
Expand All @@ -10981,7 +10981,7 @@ function Uninstall-Package
}
}

if($artfactType -eq $script:PSArtifactTypeModule)
if($artifactType -eq $script:PSArtifactTypeModule)
{
$moduleName = $packageName
$InstalledModuleInfo = $script:PSGetInstalledModules["$($moduleName)$($version)"]
Expand Down Expand Up @@ -11122,7 +11122,7 @@ function Uninstall-Package

Write-Output -InputObject $InstalledModuleInfo.SoftwareIdentity
}
elseif($artfactType -eq $script:PSArtifactTypeScript)
elseif($artifactType -eq $script:PSArtifactTypeScript)
{
$scriptName = $packageName
$InstalledScriptInfo = $script:PSGetInstalledScripts["$($scriptName)$($version)"]
Expand Down Expand Up @@ -11189,7 +11189,7 @@ function Uninstall-Package
$scriptFilePath = Microsoft.PowerShell.Management\Join-Path -Path $scriptBase `
-ChildPath "$($scriptName).ps1"

$installledScriptInfoFilePath = Microsoft.PowerShell.Management\Join-Path -Path $installedScriptInfoPath `
$installedScriptInfoFilePath = Microsoft.PowerShell.Management\Join-Path -Path $installedScriptInfoPath `
-ChildPath "$($scriptName)_$($script:InstalledScriptInfoFileName)"

# Remove the script file and it's corresponding InstalledScriptInfo.xml
Expand All @@ -11202,9 +11202,9 @@ function Uninstall-Package
-Confirm:$false -WhatIf:$false
}

if(Microsoft.PowerShell.Management\Test-Path -Path $installledScriptInfoFilePath -PathType Leaf)
if(Microsoft.PowerShell.Management\Test-Path -Path $installedScriptInfoFilePath -PathType Leaf)
{
Microsoft.PowerShell.Management\Remove-Item -Path $installledScriptInfoFilePath `
Microsoft.PowerShell.Management\Remove-Item -Path $installedScriptInfoFilePath `
-Force `
-ErrorAction SilentlyContinue `
-WarningAction SilentlyContinue `
Expand Down
Loading