1212 modules to be published (i.e. .\AWSPowerShell, .\AWSPowerShell.NetCore, and
1313 .\AWS.Tools).
1414
15- Publishing is done using the Publish-PSResource cmdlet of the PSResourceGet
15+ Publishing is done using the Publish-Module cmdlet of the PowerShellGet
1616 module. This module must be installed either in user scope or globally
1717 before this script can be used.
1818
@@ -87,7 +87,7 @@ $ErrorActionPreference = "Stop"
8787$paramSetRemoteName = " remote"
8888$paramSetLocalName = " local"
8989
90- Import-Module Microsoft.PowerShell.PSResourceGet
90+ Import-Module - Name " PowerShellGet "
9191
9292# Import DynamoDBv2 needed to update the PackageVersions table.
9393if ($PSCmdlet.ParameterSetName -eq $paramSetRemoteName ) {
@@ -101,7 +101,7 @@ if ($PSCmdlet.ParameterSetName -eq $paramSetRemoteName) {
101101}
102102elseif ($PSCmdlet.ParameterSetName -eq $paramSetLocalName ){
103103 # validate if the LocalRepositoryName exists
104- $localRepo = Get-PSResourceRepository - Name $LocalRepositoryName - ErrorAction SilentlyContinue
104+ $localRepo = Get-PSRepository - Name $LocalRepositoryName - ErrorAction SilentlyContinue
105105 if (-not $localRepo ){
106106 throw " Local repository $LocalRepositoryName does not exist."
107107 }
@@ -125,16 +125,17 @@ if (-not $DryRun -and $PSCmdlet.ParameterSetName -eq $paramSetRemoteName) {
125125 $ApiKey = ((Get-SECSecretValue - SecretId $SecretId - Region $SecretRegion - ProfileName $SecretReaderProfile ).SecretString | ConvertFrom-Json ).$SecretKey
126126}
127127
128- $commonArgs = @ {
129- ' ApiKey ' = $LocalRepositoryNuGetApiKey
130- ' SkipDependenciesCheck ' = $true
131- ' SkipModuleManifestValidate ' = $true
132- ' Repository ' = $LocalRepositoryName
128+ if ( $PSCmdlet .ParameterSetName -eq $paramSetRemoteName ) {
129+ $commonArgs = @ {
130+ ' NuGetApiKey ' = $ApiKey
131+ ' Repository ' = " PSGallery "
132+ }
133133}
134-
135- if ($PSCmdlet.ParameterSetName -eq $paramSetRemoteName ) {
136- $commonArgs.ApiKey = $ApiKey
137- $commonArgs.Repository = " PSGallery"
134+ else {
135+ $commonArgs = @ {
136+ ' NuGetApiKey' = $LocalRepositoryNuGetApiKey
137+ ' Repository' = $LocalRepositoryName
138+ }
138139}
139140
140141function PublishRecursive ([string ]$modulePath ) {
@@ -169,7 +170,7 @@ function PublishRecursive([string]$modulePath) {
169170 Write-Host " -DryRun specified, skipped actual publish and PackageVersions update of $modulePath "
170171 }
171172 else {
172- Publish-PSResource - Path $modulePath @commonArgs
173+ Publish-Module - Path $modulePath @commonArgs - Force
173174 if ($PSCmdlet.ParameterSetName -eq $paramSetRemoteName ) {
174175 Update-ModulePackageVersion - modulePath $modulePath - versionNumber $manifestData.ModuleVersion - repository " PSGallery" - profileName $UpdatePackageVersionsProfile
175176 }
@@ -181,7 +182,7 @@ function PublishRecursive([string]$modulePath) {
181182 # We could have failed because the module was already published (possible in case we run this script multiple times)
182183 if ($PSCmdlet.ParameterSetName -eq $paramSetRemoteName ) {
183184 try {
184- Find-PSResource - Repository ' PSGallery ' - Type ' Module' - Name ([System.IO.Path ]::GetFileNameWithoutExtension($manifest )) - Version $manifestData.ModuleVersion
185+ Find-Module ([System.IO.Path ]::GetFileNameWithoutExtension($manifest )) - RequiredVersion $manifestData.ModuleVersion
185186 Write-Host " Successfully found module $modulePath version $ ( $manifestData.ModuleVersion ) already on the gallery"
186187 if ($DryRun ) {
187188 Write-Host " -DryRun specified, skipped PackageVersions update of $modulePath in catch."
0 commit comments