diff --git a/src/code/PowerShellGet.csproj b/src/code/PowerShellGet.csproj index 6d580abac..dbd51ee95 100644 --- a/src/code/PowerShellGet.csproj +++ b/src/code/PowerShellGet.csproj @@ -15,12 +15,12 @@ - - - - - - + + + + + + diff --git a/src/code/PublishPSResource.cs b/src/code/PublishPSResource.cs index f80f0ca5c..c3c465e63 100644 --- a/src/code/PublishPSResource.cs +++ b/src/code/PublishPSResource.cs @@ -1008,7 +1008,7 @@ private bool PushNupkg(string outputNupkgDir, string repoName, string repoUri, o PushRunner.Run( settings: Settings.LoadDefaultSettings(root: null, configFileName: null, machineWideSettings: null), sourceProvider: new PackageSourceProvider(settings), - packagePath: fullNupkgFile, + packagePaths: new List { fullNupkgFile }, source: publishLocation, apiKey: ApiKey, symbolSource: null, diff --git a/test/InstallPSResource.Tests.ps1 b/test/InstallPSResource.Tests.ps1 index 2f82c537e..e2666efb0 100644 --- a/test/InstallPSResource.Tests.ps1 +++ b/test/InstallPSResource.Tests.ps1 @@ -96,13 +96,27 @@ Describe 'Test Install-PSResource for Module' { $pkg.Version | Should -Be "3.0.0.0" } - It "Should not install resource with incorrectly formatted version such as " -TestCases @( - @{Version='(1.0.0.0)'; Description="exclusive version (1.0.0.0)"}, - @{Version='[1-0-0-0]'; Description="version formatted with invalid delimiter [1-0-0-0]"} - ) { - param($Version, $Description) + # TODO: Update this test and others like it that use try/catch blocks instead of Should -Throw + It "Should not install resource with incorrectly formatted version such as exclusive version (1.0.0.0)" { + $Version = "(1.0.0.0)" + try { + Install-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue + } + catch + {} + $Error[0].FullyQualifiedErrorId | Should -be "IncorrectVersionFormat,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" + + $res = Get-PSResource $testModuleName + $res | Should -BeNullOrEmpty + } - Install-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue + It "Should not install resource with incorrectly formatted version such as version formatted with invalid delimiter [1-0-0-0]" { + $Version="[1-0-0-0]" + try { + Install-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue + } + catch + {} $Error[0].FullyQualifiedErrorId | Should -be "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" $res = Get-PSResource $testModuleName diff --git a/test/SavePSResource.Tests.ps1 b/test/SavePSResource.Tests.ps1 index 1c3b612e1..b9ddac47d 100644 --- a/test/SavePSResource.Tests.ps1 +++ b/test/SavePSResource.Tests.ps1 @@ -99,17 +99,30 @@ Describe 'Test Save-PSResource for PSResources' { $pkgDirVersion.Name | Should -Be "3.0.0.0" } - It "Should not save resource with incorrectly formatted version such as " -TestCases @( - @{Version='(1.0.0.0)'; Description="exclusive version (1.0.0.0)"}, - @{Version='[1-0-0-0]'; Description="version formatted with invalid delimiter [1-0-0-0]"} - ) { - param($Version, $Description) + It "Should not save resource with incorrectly formatted version such as exclusive version (1.0.0.0)" { + $Version="(1.0.0.0)" + try { + Save-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -Path $SaveDir -ErrorAction SilentlyContinue -TrustRepository + } + catch + {} + $pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $testModuleName + $pkgDir | Should -BeNullOrEmpty + $Error.Count | Should -Not -Be 0 + $Error[0].FullyQualifiedErrorId | Should -Be "IncorrectVersionFormat,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource" + } - Save-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -Path $SaveDir -ErrorVariable err -ErrorAction SilentlyContinue -TrustRepository + It "Should not save resource with incorrectly formatted version such as version formatted with invalid delimiter [1-0-0-0]"{ + $Version = "[1-0-0-0]" + try { + Save-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -Path $SaveDir -ErrorAction SilentlyContinue -TrustRepository + } + catch + {} $pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $testModuleName $pkgDir | Should -BeNullOrEmpty - $err.Count | Should -Not -Be 0 - $err[0].FullyQualifiedErrorId | Should -BeExactly "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource" + $Error.Count | Should -Not -Be 0 + $Error[0].FullyQualifiedErrorId | Should -BeExactly "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource" } It "Save resource when given Name, Version '*', should install the latest version" { diff --git a/test/UninstallPSResource.Tests.ps1 b/test/UninstallPSResource.Tests.ps1 index 0c0850e60..a0bc31e30 100644 --- a/test/UninstallPSResource.Tests.ps1 +++ b/test/UninstallPSResource.Tests.ps1 @@ -152,7 +152,11 @@ Describe 'Test Uninstall-PSResource for Modules' { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository - Uninstall-PSResource -Name $testModuleName -Version $Version + try { + Uninstall-PSResource -Name $testModuleName -Version $Version -ErrorAction SilentlyContinue + } + catch + {} $pkg = Get-PSResource $testModuleName -Version "1.0.0.0" $pkg.Version | Should -Be "1.0.0.0" }