Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Changelog
## 1.6.7

Bug fixes
- Resolved Install/Save-Module error in PSCore 6.1.0-preview.4 on Ubuntu 18.04 OS (WSL/Azure) (#313)
- Updated error message in Save-Module cmdlet when the specified path is not accessible (#313)
- Added few additional verbose messages (#313)

## 1.6.6

Dependency Updates
Expand Down
7 changes: 7 additions & 0 deletions PowerShellGet/PSGet.Resource.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,12 @@ ConvertFrom-StringData @'
FailedToParseRequiredScripts=Cannot parse REQUIREDSCRIPTS '{0}'. Acceptable formats are: '{1}'.
FailedToParseRequiredScriptsVersion=Version format error: {0}, '{1}'. Acceptable formats are: '{2}'.
PublishersMismatchAsWarning=Module '{0}' version '{1}' published by '{2}' will be superceded by version '{3}' published by '{4}'. If you do not trust the new publisher, uninstall the module.
UnableToDownloadThePackage=The PackageManagement provider '{0}' is unable to download the package '{1}' version '{2}' to '{3}' path.
ValidatingTheModule=Validating the '{0}' module contents under '{1}' path.
ModuleValidationFailed=Unable to validate the '{0}' module contents under '{1}' path.
ValidatedModuleManifestFile=Test-ModuleManifest successfully validated the module manifest file '{0}'.
ValidateModuleAuthenticodeSignature=Validating the authenticode signature and publisher of the catalog file or module manifest file of the module '{0}'.
ValidateModuleCommandAlreadyAvailable=Checking for possible command collisions for the module '{0}' commands.
UnauthorizedAccessError=Access to the path '{0}' is denied.
###PSLOC
'@
9 changes: 8 additions & 1 deletion PowerShellGet/PowerShellGet.psd1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
RootModule = 'PSModule.psm1'
ModuleVersion = '1.6.6'
ModuleVersion = '1.6.7'
GUID = '1d73a601-4a6c-43c5-ba3f-619b18bbb404'
Author = 'Microsoft Corporation'
CompanyName = 'Microsoft Corporation'
Expand Down Expand Up @@ -54,6 +54,13 @@ PrivateData = @{
ProjectUri = 'https://go.microsoft.com/fwlink/?LinkId=828955'
LicenseUri = 'https://go.microsoft.com/fwlink/?LinkId=829061'
ReleaseNotes = @'
## 1.6.7

Bug fixes
- Resolved Install/Save-Module error in PSCore 6.1.0-preview.4 on Ubuntu 18.04 OS (WSL/Azure) (#313)
- Updated error message in Save-Module cmdlet when the specified path is not accessible (#313)
- Added few additional verbose messages (#313)

## 1.6.6

Dependency Updates
Expand Down
25 changes: 19 additions & 6 deletions PowerShellGet/private/functions/Copy-Module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@ function Copy-Module
[Parameter(Mandatory=$true)]
[ValidateNotNull()]
[PSCustomObject]
$PSGetItemInfo
$PSGetItemInfo,

[Parameter(Mandatory=$false)]
[Switch]
$IsSavePackage
)

$ev = $null
$message = $LocalizedData.AdministratorRightsNeededOrSpecifyCurrentUserScope
if(-not $IsSavePackage)
{
$message = $LocalizedData.AdministratorRightsNeededOrSpecifyCurrentUserScope
$errorId = 'AdministratorRightsNeededOrSpecifyCurrentUserScope'
}
else
{
$message = $LocalizedData.UnauthorizedAccessError -f $DestinationPath
$errorId = 'UnauthorizedAccessError'
}

if(Microsoft.PowerShell.Management\Test-Path $DestinationPath)
{
Expand All @@ -38,7 +51,7 @@ function Copy-Module
$script:IsRunningAsElevated = $false
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $message `
-ErrorId "AdministratorRightsNeededOrSpecifyCurrentUserScope" `
-ErrorId $errorId `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidArgument `
-ExceptionObject $ev
Expand All @@ -61,13 +74,13 @@ function Copy-Module
$script:IsRunningAsElevated = $false
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $message `
-ErrorId "AdministratorRightsNeededOrSpecifyCurrentUserScope" `
-ErrorId $errorId `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidArgument `
-ExceptionObject $ev
}

Microsoft.PowerShell.Management\Copy-Item -Path "$SourcePath\*" `
Microsoft.PowerShell.Management\Copy-Item -Path (Microsoft.PowerShell.Management\Join-Path -Path $SourcePath -ChildPath '*') `
-Destination $DestinationPath `
-Force `
-Recurse `
Expand All @@ -81,7 +94,7 @@ function Copy-Module
$script:IsRunningAsElevated = $false
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $message `
-ErrorId "AdministratorRightsNeededOrSpecifyCurrentUserScope" `
-ErrorId $errorId `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidArgument `
-ExceptionObject $ev
Expand Down
38 changes: 22 additions & 16 deletions PowerShellGet/private/functions/Install-PackageUtility.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@ function Install-PackageUtility

$ProviderOptions = @{
Destination=$tempDestination;
ExcludeVersion=$true
}

if($InstalledItemsList)
Expand All @@ -557,7 +556,7 @@ function Install-PackageUtility

$YesToAll = $false
$NoToAll = $false

foreach($pkg in $installedPkgs)
{
if($request.IsCanceled)
Expand Down Expand Up @@ -590,16 +589,21 @@ function Install-PackageUtility
# Get actual artifact type from the package
$packageType = $script:PSArtifactTypeModule
$installLocation = $destinationModulePath
$tempPackagePath = Microsoft.PowerShell.Management\Join-Path -Path $tempDestination -ChildPath $pkg.Name
if(Microsoft.PowerShell.Management\Test-Path -Path $tempPackagePath)
# Below logic handles the package folder name with version.
$tempPackagePath = Microsoft.PowerShell.Management\Join-Path -Path $tempDestination -ChildPath "$($pkg.Name).$($pkg.Version)"
if(-not (Microsoft.PowerShell.Management\Test-Path -Path $tempPackagePath -PathType Container))
{
$packageFiles = Microsoft.PowerShell.Management\Get-ChildItem -Path $tempPackagePath -Recurse -Exclude "*.nupkg","*.nuspec"
$message = $LocalizedData.UnableToDownloadThePackage -f ($provider.ProviderName, $pkg.Name, $pkg.Version, $tempPackagePath)
Write-Error -Message $message -ErrorId 'UnableToDownloadThePackage' -Category InvalidOperation
return
}

if($packageFiles -and $packageFiles.GetType().ToString() -eq 'System.IO.FileInfo' -and $packageFiles.Name -eq "$($pkg.Name).ps1")
{
$packageType = $script:PSArtifactTypeScript
$installLocation = $destinationscriptPath
}
$packageFiles = Microsoft.PowerShell.Management\Get-ChildItem -Path $tempPackagePath -Recurse -Exclude "*.nupkg","*.nuspec"

if($packageFiles -and $packageFiles.GetType().ToString() -eq 'System.IO.FileInfo' -and $packageFiles.Name -eq "$($pkg.Name).ps1")
{
$packageType = $script:PSArtifactTypeScript
$installLocation = $destinationscriptPath
}

$AdditionalParams = @{}
Expand Down Expand Up @@ -660,13 +664,13 @@ function Install-PackageUtility
continue
}

$sourceModulePath = $tempPackagePath
if($psgItemInfo.PowerShellGetFormatVersion -eq "1.0")
{
$sourceModulePath = Microsoft.PowerShell.Management\Join-Path $tempDestination "$($pkg.Name)\Content\*\$script:ModuleReferences\$($pkg.Name)"
}
else
{
$sourceModulePath = Microsoft.PowerShell.Management\Join-Path $tempDestination $pkg.Name
$sourceModulePath = Microsoft.PowerShell.Management\Join-Path -Path $sourceModulePath -ChildPath 'Content' |
Microsoft.PowerShell.Management\Join-Path -ChildPath '*' |
Microsoft.PowerShell.Management\Join-Path -ChildPath $script:ModuleReferences |
Microsoft.PowerShell.Management\Join-Path -ChildPath $pkg.Name
}

#Prompt if module requires license Acceptance
Expand Down Expand Up @@ -724,13 +728,15 @@ function Install-PackageUtility
if(-not $IsSavePackage)
{
$CurrentModuleInfo = Test-ValidManifestModule -ModuleBasePath $sourceModulePath `
-ModuleName $pkg.Name `
-InstallLocation $InstallLocation `
-AllowClobber:$AllowClobber `
-SkipPublisherCheck:$SkipPublisherCheck `
-IsUpdateOperation:$installUpdate

if(-not $CurrentModuleInfo)
{
Write-Verbose -Message ($LocalizedData.ModuleValidationFailed -f $ModuleName,$ModuleBasePath)
# This Install-Package provider API gets called once per an item/package/SoftwareIdentity.
# Return if there is an error instead of continuing further to install the dependencies or current module.
#
Expand Down Expand Up @@ -842,7 +848,7 @@ function Install-PackageUtility
$psgItemInfo.Version = $CurrentModuleInfo.Version
}

Copy-Module -SourcePath $sourceModulePath -DestinationPath $destinationModulePath -PSGetItemInfo $psgItemInfo
Copy-Module -SourcePath $sourceModulePath -DestinationPath $destinationModulePath -PSGetItemInfo $psgItemInfo -IsSavePackage:$IsSavePackage

if(-not $IsSavePackage)
{
Expand Down
81 changes: 49 additions & 32 deletions PowerShellGet/private/functions/Test-ValidManifestModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ function Test-ValidManifestModule
[string]
$ModuleBasePath,

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]
$ModuleName,

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]
Expand All @@ -27,45 +32,57 @@ function Test-ValidManifestModule
$IsUpdateOperation
)

$moduleName = Microsoft.PowerShell.Management\Split-Path $ModuleBasePath -Leaf
$manifestPath = Join-PathUtility -Path $ModuleBasePath -ChildPath "$moduleName.psd1" -PathType File
Write-Verbose -Message ($LocalizedData.ValidatingTheModule -f $ModuleName,$ModuleBasePath)
$manifestPath = Join-PathUtility -Path $ModuleBasePath -ChildPath "$ModuleName.psd1" -PathType File
$PSModuleInfo = $null

if(Microsoft.PowerShell.Management\Test-Path $manifestPath)
if(-not (Microsoft.PowerShell.Management\Test-Path $manifestPath -PathType Leaf))
{
$PSModuleInfo = Microsoft.PowerShell.Core\Test-ModuleManifest -Path $manifestPath -ErrorAction SilentlyContinue -WarningAction SilentlyContinue

if(-not $PSModuleInfo)
{
$message = $LocalizedData.InvalidPSModule -f ($moduleName)
ThrowError -ExceptionName 'System.InvalidOperationException' `
-ExceptionMessage $message `
-ErrorId 'InvalidManifestModule' `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidOperation
}
elseif($script:IsWindows)
{
$ValidationResult = Validate-ModuleAuthenticodeSignature -CurrentModuleInfo $PSModuleInfo `
-InstallLocation $InstallLocation `
-IsUpdateOperation:$IsUpdateOperation `
-SkipPublisherCheck:$SkipPublisherCheck
$message = $LocalizedData.PathNotFound -f ($manifestPath)
ThrowError -ExceptionName 'System.InvalidOperationException' `
-ExceptionMessage $message `
-ErrorId 'PathNotFound' `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidOperation
}

if($ValidationResult)
{
# Checking for the possible command clobbering.
$ValidationResult = Validate-ModuleCommandAlreadyAvailable -CurrentModuleInfo $PSModuleInfo `
-InstallLocation $InstallLocation `
-AllowClobber:$AllowClobber `
-IsUpdateOperation:$IsUpdateOperation
$PSModuleInfo = Microsoft.PowerShell.Core\Test-ModuleManifest -Path $manifestPath -ErrorAction SilentlyContinue -WarningAction SilentlyContinue

if(-not $PSModuleInfo)
{
$message = $LocalizedData.InvalidPSModule -f ($moduleName)
ThrowError -ExceptionName 'System.InvalidOperationException' `
-ExceptionMessage $message `
-ErrorId 'InvalidManifestModule' `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidOperation
}
else
{
Write-Verbose -Message ($LocalizedData.ValidatedModuleManifestFile -f $ModuleBasePath)
}

}
if($script:IsWindows)
{
Write-Verbose -Message ($LocalizedData.ValidateModuleAuthenticodeSignature -f $ModuleName)
$ValidationResult = Validate-ModuleAuthenticodeSignature -CurrentModuleInfo $PSModuleInfo `
-InstallLocation $InstallLocation `
-IsUpdateOperation:$IsUpdateOperation `
-SkipPublisherCheck:$SkipPublisherCheck

if($ValidationResult)
{
# Checking for the possible command clobbering.
Write-Verbose -Message ($LocalizedData.ValidateModuleCommandAlreadyAvailable -f $ModuleName)
$ValidationResult = Validate-ModuleCommandAlreadyAvailable -CurrentModuleInfo $PSModuleInfo `
-InstallLocation $InstallLocation `
-AllowClobber:$AllowClobber `
-IsUpdateOperation:$IsUpdateOperation
}

if(-not $ValidationResult)
{
$PSModuleInfo = $null
}
if(-not $ValidationResult)
{
$PSModuleInfo = $null
}
}

Expand Down