diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dd52600a..f69478e4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # CHANGELOG +## 1.0.3 + +### Bug Fixes +- Bug fix for null package version in `Install-PSResource` + ## 1.0.2 ### Bug Fixes diff --git a/src/Microsoft.PowerShell.PSResourceGet.psd1 b/src/Microsoft.PowerShell.PSResourceGet.psd1 index bac80a5da..8a5ea771b 100644 --- a/src/Microsoft.PowerShell.PSResourceGet.psd1 +++ b/src/Microsoft.PowerShell.PSResourceGet.psd1 @@ -4,7 +4,7 @@ @{ RootModule = './Microsoft.PowerShell.PSResourceGet.dll' NestedModules = @('./Microsoft.PowerShell.PSResourceGet.psm1') - ModuleVersion = '1.0.2' + ModuleVersion = '1.0.3' CompatiblePSEditions = @('Core', 'Desktop') GUID = 'e4e0bda1-0703-44a5-b70d-8fe704cd0643' Author = 'Microsoft Corporation' @@ -55,6 +55,11 @@ ProjectUri = 'https://go.microsoft.com/fwlink/?LinkId=828955' LicenseUri = 'https://go.microsoft.com/fwlink/?LinkId=829061' ReleaseNotes = @' +## 1.0.3 + +### Bug Fixes +- Bug fix for null package version in `Install-PSResource` + ## 1.0.2 ### Bug Fixes diff --git a/src/code/InstallHelper.cs b/src/code/InstallHelper.cs index 3decd4a38..5171299d2 100644 --- a/src/code/InstallHelper.cs +++ b/src/code/InstallHelper.cs @@ -790,6 +790,10 @@ private Hashtable BeginPackageInstall( pkgToInstall.RepositorySourceLocation = repository.Uri.ToString(); pkgToInstall.AdditionalMetadata.TryGetValue("NormalizedVersion", out string pkgVersion); + if (pkgVersion == null) + { + pkgVersion = pkgToInstall.Version.ToString(); + } // Check to see if the pkg is already installed (ie the pkg is installed and the version satisfies the version range provided via param) if (!_reinstall) diff --git a/src/code/Microsoft.PowerShell.PSResourceGet.csproj b/src/code/Microsoft.PowerShell.PSResourceGet.csproj index 60d8c5d93..aeda6847f 100644 --- a/src/code/Microsoft.PowerShell.PSResourceGet.csproj +++ b/src/code/Microsoft.PowerShell.PSResourceGet.csproj @@ -5,9 +5,9 @@ Library Microsoft.PowerShell.PSResourceGet Microsoft.PowerShell.PSResourceGet - 1.0.2.0 - 1.0.2 - 1.0.2 + 1.0.3.0 + 1.0.3 + 1.0.3 net472;netstandard2.0 9.0 true diff --git a/src/code/V2ServerAPICalls.cs b/src/code/V2ServerAPICalls.cs index 6a05d6d7b..60f33d87e 100644 --- a/src/code/V2ServerAPICalls.cs +++ b/src/code/V2ServerAPICalls.cs @@ -677,13 +677,16 @@ public override Stream InstallPackage(string packageName, string packageVersion, Stream results = new MemoryStream(); if (string.IsNullOrEmpty(packageVersion)) { - results = InstallName(packageName, out errRecord); - } - else - { - results = InstallVersion(packageName, packageVersion, out errRecord); + errRecord = new ErrorRecord( + exception: new ArgumentNullException($"Package version could not be found for {packageName}"), + "PackageVersionNullOrEmptyError", + ErrorCategory.InvalidArgument, + _cmdletPassedIn); + + return results; } + results = InstallVersion(packageName, packageVersion, out errRecord); return results; } diff --git a/src/code/V3ServerAPICalls.cs b/src/code/V3ServerAPICalls.cs index 5d5e6687b..2be715e9e 100644 --- a/src/code/V3ServerAPICalls.cs +++ b/src/code/V3ServerAPICalls.cs @@ -285,6 +285,8 @@ public override FindResults FindVersionWithTag(string packageName, string versio /// /// Installs a specific package. + /// User may request to install package with or without providing version (as seen in examples below), but prior to calling this method the package is located and package version determined. + /// Therefore, package version should not be null in this method. /// Name: no wildcard support. /// Examples: Install "PowerShellGet" /// Install "PowerShellGet" -Version "3.0.0" @@ -295,13 +297,17 @@ public override Stream InstallPackage(string packageName, string packageVersion, Stream results = new MemoryStream(); if (string.IsNullOrEmpty(packageVersion)) { - results = InstallName(packageName, out errRecord); - } - else - { - results = InstallVersion(packageName, packageVersion, out errRecord); + errRecord = new ErrorRecord( + exception: new ArgumentNullException($"Package version could not be found for {packageName}"), + "PackageVersionNullOrEmptyError", + ErrorCategory.InvalidArgument, + _cmdletPassedIn); + + return results; } + results = InstallVersion(packageName, packageVersion, out errRecord); + return results; }