Unable to publish an update to an existing Powershell module to our Artifact Store.
In my script I register my repositories and Package Sources:
Register-PSRepository -Name ArtifactoryDev -SourceLocation $NuGetDevUrl -PublishLocation $NuGetDevUrl -InstallationPolicy Trusted -Credential $Cred
Register-PackageSource -Name ArtifactoryDev -ProviderName NuGet -Location $NuGetDevUrl -Trusted -Credential $Cred
I then, near the end of my script try to publish the module to update our existing one in Artifactory:
Publish-Module -Path $Module.Path -Repository $RepositoryName -NuGetApiKey "$($ArtifactoryUser):$($ArtifactoryToken)" -Credential $Cred -Force -ErrorAction Stop -Verbose -Debug
I am getting the following error
2019-06-27T12:12:24.2452350Z ##[error]PackageManagement\Get-PackageSource : Unable to find repository 'ArtifactoryDev'. Use Get-PSRepository to see all
available repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.1.5\PSModule.psm1:9360 char:35
+ ... ckageSources = PackageManagement\Get-PackageSource @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...etPackageSource:GetPackageSource) [Get-PackageSource]
, Exception
+ FullyQualifiedErrorId : SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource
To check the repository does exist I thought to call Get-PackageSource -Name ArtifatoryDev
and I can see it in the results:
Name ProviderName IsTrusted Location
---- ------------ --------- --------
ArtifactoryDev PowerShellGet True http://myremoterepo
I have had similar issues with the publish function. Have you tried to unregister and reregister the repo just before the publish? I have found that does the trick. For some reason, the publish module does an anon call to the repo to check versions (I think) before publishing and if the repo is secure (or doesn't have anon auth allowed) you can get errors. By unregistering and reregistering the repo just before the publish, I've found that is somehow gets around the anon call... not sure exactly why.