Skip to content

Azure DevOps Feed - Issue when publishing and installing module #1465

@denisky

Description

@denisky

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

I'm trying to publish my PowerShell module to an Azure DevOps Feed.

I managed to register my feed using Register-PSResourceRepository, but I noticed that it requires a trailing / otherwise I'm unable to publish the module using Publish-PSResource.

Here is there error I'm getting:

Command

C:\Test>Publish-PSResource -Path .\TestModule\ -Repository test -ApiKey AzureDevOps -SkipDependenciesCheck
Publish-PSResource: Repository 'test': Response status code does not indicate success: 404 (Not Found).

Exception

Exception             :
    Type    : System.ArgumentException
    Message : Repository 'test': Response status code does not indicate success: 404 (Not Found).
    HResult : -2147024809
TargetObject          : Microsoft.PowerShell.PSResourceGet.Cmdlets.PublishPSResource
CategoryInfo          : PermissionDenied: (Microsoft.PowerShel…s.PublishPSResource:PublishPSResource)
[Publish-PSResource], ArgumentException
FullyQualifiedErrorId : HTTPRequestError,Microsoft.PowerShell.PSResourceGet.Cmdlets.PublishPSResource
InvocationInfo        :
    MyCommand        : Publish-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 179
    Line             : Publish-PSResource -Path .\TestModule\ -Repository test -ApiKey AzureDevOps
-SkipDependenciesCheck
    PositionMessage  : At line:1 char:1
                       + Publish-PSResource -Path .\TestModule\ -Repository test -Ap …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Publish-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :

If I add the trailing / it works as expected, but I'm encountering another issue when installing the module.

Command

C:\Test>Install-PSResource TestModule -Repository test -Version 1.0.0-alpha1 -Prerelease
Install-PSResource: Repository 'test' is not a known repository type that is supported. Please file an issue for support at https://github.com/PowerShell/PSResourceGet/issues
Install-PSResource: Package(s) 'TestModule' could not be installed from repository ''.

Exception

Exception             :
    Type    : Microsoft.PowerShell.PSResourceGet.UtilClasses.ResourceNotFoundException
    Message : Package(s) 'TestModule' could not be installed from repository ''.
    HResult : -2146233088
TargetObject          : Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
CategoryInfo          : InvalidData: (Microsoft.PowerShel…s.InstallPSResource:InstallPSResource) [Install-PSResource],
ResourceNotFoundException
FullyQualifiedErrorId : InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
InvocationInfo        :
    MyCommand        : Install-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 10
    Line             : Install-PSResource TestModule -Repository test -Version 1.0.0-alpha1
-Prerelease
    PositionMessage  : At line:1 char:1
                       + Install-PSResource TestModule -Repository test -V …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Install-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :

If register the repository again with not trailing / I'm getting a different error.

Command

C:\Test>Install-PSResource TestModule -Repository test -Version 1.0.0-alpha1 -Prerelease
Install-PSResource: 'Response status code does not indicate success: 404 (Not Found).' Request sent: 'https://pkgs.dev.azure.com/MyOrg/MyProject/_packaging/MyFeed/nuget/v2/package/TestModule/1.0.0-alpha1'

Exception

Exception             :
    Type       : Microsoft.PowerShell.PSResourceGet.UtilClasses.ResourceNotFoundException
    TargetSite :
        Name          : MoveNext
        DeclaringType :
Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls+<SendV2RequestForContentAsync>d__38,
Microsoft.PowerShell.PSResourceGet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
        MemberType    : Method
        Module        : Microsoft.PowerShell.PSResourceGet.dll
    Message    : 'Response status code does not indicate success: 404 (Not Found).' Request sent: 'https://pkgs.dev.azu
re.com/MyOrg/MyProject/_packaging/MyFeed/nuget/v2/package/TestModule/1.0.0-alpha1'
    Source     : Microsoft.PowerShell.PSResourceGet
    HResult    : -2146233088
    StackTrace :
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls.SendV2RequestForContentAsync(HttpRequestMessage
message, HttpClient s_client)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls.HttpRequestCallForContent(String requestUrlV2,
ErrorRecord& errRecord)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls.InstallVersion(String packageName, String version,
ErrorRecord& errRecord)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls.InstallPackage(String packageName, String
packageVersion, Boolean includePrerelease, ErrorRecord& errRecord)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.BeginPackageInstall(VersionType searchVersionType,
NuGetVersion specificVersion, VersionRange versionRange, String pkgNameToInstall, PSRepositoryInfo repository,
ServerApiCall currentServer, ResponseUtil currentResponseUtil, String tempInstallPath, Hashtable packagesHash,
ErrorRecord& errRecord)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.InstallPackages(String[] pkgNamesToInstall,
PSRepositoryInfo repository, ServerApiCall currentServer, ResponseUtil currentResponseUtil, ScopeType scope, Boolean
skipDependencyCheck, FindHelper findHelper)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.ProcessRepositories(String[] repository, Boolean
trustRepository, Boolean skipDependencyCheck, ScopeType scope)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.BeginInstallPackages(String[] names, VersionRange
versionRange, NuGetVersion nugetVersion, VersionType versionType, String versionString, Boolean prerelease, String[]
repository, Boolean acceptLicense, Boolean quiet, Boolean reinstall, Boolean force, Boolean trustRepository, Boolean
noClobber, Boolean asNupkg, Boolean includeXml, Boolean skipDependencyCheck, Boolean authenticodeCheck, Boolean
savePkg, List`1 pathsToInstallPkg, Nullable`1 scope, String tmpPath, HashSet`1 pkgsInstalled)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource.ProcessInstallHelper(String[] pkgNames, String
pkgVersion, Boolean pkgPrerelease, String[] pkgRepository, PSCredential pkgCredential, InstallPkgParams
reqResourceParams)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo          : NotSpecified: (:) [Install-PSResource], ResourceNotFoundException
FullyQualifiedErrorId : Microsoft.PowerShell.PSResourceGet.UtilClasses.ResourceNotFoundException,Microsoft.PowerShell.P
SResourceGet.Cmdlets.InstallPSResource
InvocationInfo        :
    MyCommand        : Install-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 12
    Line             : Install-PSResource TestModule -Repository test -Version 1.0.0-alpha1 -Prerelease
    PositionMessage  : At line:1 char:1
                       + Install-PSResource TestModule  -Repository test -Version 1.0+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Install-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Expected behavior

It should download the NuGet from the feed, and install the PowerShell Module.

Actual behavior

It is returning 404 (Not Found).

Error details

No response

Environment data

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     0.9.0      rc1        Microsoft.PowerShell.PSResourceGet  {Find-PSResource, Get-InstalledPSResource, Get-PS…


Name                           Value
----                           -----
PSVersion                      7.3.9
PSEdition                      Core
GitCommitId                    7.3.9
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions