OneGet / oneget

PackageManagement (aka OneGet) is a package manager for Windows
MIT License
2.38k stars 190 forks source link

Unable to register Azure DevOps feed using Register-PSRepository #486

Open stuartluscombe opened 4 years ago

stuartluscombe commented 4 years ago

PackageManagement: 1.4.6 PowerShellGet: 2.2.3 PowerShell: 5.1

When trying to register an Azure DevOps artifact feed as a PowerShell repository as per the guide at https://docs.microsoft.com/en-us/azure/devops/artifacts/tutorials/private-powershell-library?view=azure-devops I keep getting errors during the registration.

Steps to reproduce:

Publish a PowerShell module to an Azure Artifact feed Create a PAT with READ access only Create a PSCredential object with your Azure DevOps e-mail and the PAT as username/password. Try to register the feed using an elevated terminal

 sluscombe@LT-18120 > C:\..\system32 > Register-PSRepository -Name "MyModule" -SourceLocation "https://pkgs.dev.azure.com/myorg/_packaging/MyModule/nuget/v2" -PublishLocation "https://pkgs.dev.azure.com/myorg/_packaging/MyModule/nuget/v2" -InstallationPolicy Trusted -Verbose -Credential $Credentials
VERBOSE: Acquiring providers for assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.4.6\fullclr\Microsoft.PackageManagement.NuGetProvider.dll
VERBOSE: Acquiring providers for assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.4.6\fullclr\Microsoft.PackageManagement.MetaProvider.PowerShell.dll
VERBOSE: Acquiring providers for assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.4.6\fullclr\Microsoft.PackageManagement.CoreProviders.dll
VERBOSE: Acquiring providers for assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.4.6\fullclr\Microsoft.PackageManagement.MsuProvider.dll
VERBOSE: Acquiring providers for assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.4.6\fullclr\Microsoft.PackageManagement.ArchiverProviders.dll
VERBOSE: Acquiring providers for assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.4.6\fullclr\Microsoft.PackageManagement.MsiProvider.dll
Register-PSRepository : The specified Uri 'https://pkgs.dev.azure.com/myorg/_packaging/MyModule/nuget/v2' for
parameter 'SourceLocation' is an invalid Web Uri. Please ensure that it meets the Web Uri requirements.
At line:1 char:1
+ Register-PSRepository -Name "MyModule" -SourceLocation "https://pkgs.d ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (https://pkgs.de...yModule/nuget/v2:String) [Register-PSRepository], Arg
   umentException
    + FullyQualifiedErrorId : InvalidWebUri,Register-PSRepository

sluscombe@LT-18120 > C:\..\system32 > $error
Register-PSRepository : The specified Uri 'https://pkgs.dev.azure.com/myorg/_packaging/MyModule/nuget/v2' for
parameter 'SourceLocation' is an invalid Web Uri. Please ensure that it meets the Web Uri requirements.
At line:1 char:1
+ Register-PSRepository -Name "MyModule" -SourceLocation "https://pkgs.d ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (https://pkgs.de...yModule/nuget/v2:String) [Register-PSRepository], Arg
   umentException
    + FullyQualifiedErrorId : InvalidWebUri,Register-PSRepository

Unable to find type [System.Net.Http.HttpClient].
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.3\PSModule.psm1:2886 char:9
+         [System.Net.Http.HttpClient]
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.Http.HttpClient:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Get-Variable : Cannot find a variable with the name 'PackageManagementProvider'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.3\PSModule.psm1:11364 char:17
+ ...         if (Get-Variable -Name PackageManagementProvider -ErrorAction ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (PackageManagementProvider:String) [Get-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.GetVariableCommand
rtb-cb commented 1 month ago

I've encountered the same issue when trying to publish a powershell module to an azure devops feed.

PS ~> Register-PSRepository -Name "PowershellFeed" -SourceLocation "https://pkgs.dev.azure.com/org/_packaging/PowershellFeed/nuget/v3" -PublishLocation "https://pkgs.dev.azure.com/org/_packaging/PowershellFeed/nuget/v3" -InstallationPolicy Trusted -Credential $credsAzureDevopsServices
Register-PSRepository : The specified Uri 'https://pkgs.dev.azure.com/org/_packaging/PowershellFeed/nuget/v3' for parameter 'SourceLocation' is an invalid Web Uri.
Please ensure that it meets the Web Uri requirements.
At line:1 char:1
+ Register-PSRepository -Name "PowershellFeed" -SourceLocation "https:/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (https://pkgs.de...llFeed/nuget/v3:String) [Register-PSRepository], ArgumentException
    + FullyQualifiedErrorId : InvalidWebUri,Register-PSRepository

PS ~> $error
Register-PSRepository : The specified Uri 'https://pkgs.dev.azure.com/org/_packaging/PowershellFeed/nuget/v3' for parameter 'SourceLocation' is an invalid Web Uri.
Please ensure that it meets the Web Uri requirements.
At line:1 char:1
+ Register-PSRepository -Name "PowershellFeed" -SourceLocation "https:/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (https://pkgs.de...llFeed/nuget/v3:String) [Register-PSRepository], ArgumentException
    + FullyQualifiedErrorId : InvalidWebUri,Register-PSRepository

Register-PSRepository : The specified Uri 'https://pkgs.dev.azure.com/org/_packaging/PowershellFeed/nuget/v3' for parameter 'SourceLocation' is an invalid Web Uri.
Please ensure that it meets the Web Uri requirements.
At line:1 char:1
+ Register-PSRepository -Name "PowershellFeed" -SourceLocation "https:/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (https://pkgs.de...llFeed/nuget/v3:String) [Register-PSRepository], ArgumentException
    + FullyQualifiedErrorId : InvalidWebUri,Register-PSRepository

Unable to find type [System.Net.Http.HttpClient].
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:6260 char:9
+         [System.Net.Http.HttpClient]
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.Http.HttpClient:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Get-Variable : Cannot find a variable with the name 'PackageManagementProvider'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4079 char:16
+ ...          if(Get-Variable -Name PackageManagementProvider -ErrorAction ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (PackageManagementProvider:String) [Get-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.GetVariableCommand

Unable to find type [Microsoft.PowerShell.Commands.PowerShellGet.Telemetry].
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:715 char:26
+ ... yMethods = ([Microsoft.PowerShell.Commands.PowerShellGet.Telemetry] | ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power...llGet.Telemetry:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound 

@stuartluscombe did you ever find a solution to this?