oneget: Find-Module fails to retrieve packages, "Unable to resolve package source"
I recently updated my packages to use PackageManagement version 1.2.3 and PowerShellGet 2.0.3 but it fails on properly finding any PowerShell modules privately hosted on Azure DevOps Artifact Service (formerly known VSTS package management service). It does not matter if a module name has been specified or not. The PSCredential object passed to Find-Module is using a personal access token.
It works perfectly fine with a combination of PackageManagement version 1.1.7.2 and PowerShellGet 2.0.3. Modules are returned by the Find-Module function every time when tried against the same artifact service.
I’ve enabled the debugging on the underlying functions to possibly identify the problem. I’ve done it with both combinations and I present the results below.
From a combination of PackageManagement version 1.2.3 and PowerShellGet 2.0.3, I’ve done the following:
PS C:\Register-PSRepository -Credential $c -Name 'DevOps_Test' -InstallationPolicy 'Trusted' -SourceLocation 'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2' -PackageManagementProvider 'Nuget' -Verbose -Debug
PS C:\Find-Module -Credential $c -Repository 'DevOps_Test' -Verbose -Debug
DEBUG: 00:00:00.0000007 Calling New() : MethodName = 'ResolvePackageSources'
DEBUG: 00:00:00.0000911 Verbose: False
DEBUG: 00:00:00.0001491 Name: DevOps_Test
DEBUG: 00:00:00.0002027 ErrorVariable: ev
DEBUG: 00:00:00.0022602 INVOKING PowerShell Fn Resolve-PackageSource with args that has length 0
DEBUG: 00:00:00.0042859 In PowerShellGet Provider - 'Resolve-PackageSource'.
DEBUG: 00:00:00.0100565 Yielding package source for DevOps_Test at location https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2
DEBUG: 00:00:00.0123623 Done calling powershell «Resolve-PackageSource» «PSModule»
DEBUG: 00:00:00.0230035 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0230713 Verbose: False
DEBUG: 00:00:00.0231209 Name: DevOps_Test
DEBUG: 00:00:00.0231658 ErrorVariable: ev
DEBUG: 00:00:00.0247962 INVOKING PowerShell Fn Get-DynamicOptions with args Provider that has length 1
DEBUG: 00:00:00.0268610 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0300406 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0401909 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0402569 Verbose: False
DEBUG: 00:00:00.0403043 Name: DevOps_Test
DEBUG: 00:00:00.0403480 ErrorVariable: ev
DEBUG: 00:00:00.0420058 INVOKING PowerShell Fn Get-DynamicOptions with args Source that has length 1
DEBUG: 00:00:00.0441884 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0504954 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:07.8385361 Calling New() : MethodName = 'ResolvePackageSources'
DEBUG: 00:00:07.8400280 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:07.8410185 ProviderName: PowerShellGet
DEBUG: 00:00:07.8419433 Verbose: False
DEBUG: 00:00:07.8428816 Name: DevOps_Test
DEBUG: 00:00:07.8436226 ErrorVariable: ev
DEBUG: 00:00:07.8445394 INVOKING PowerShell Fn Resolve-PackageSource with args that has length 0
DEBUG: 00:00:07.8456378 In PowerShellGet Provider - 'Resolve-PackageSource'.
DEBUG: 00:00:07.8511997 Yielding package source for DevOps_Test at location https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2
DEBUG: 00:00:07.8536974 Done calling powershell «Resolve-PackageSource» «PSModule»
DEBUG: 00:00:07.8581883 Calling New() : MethodName = 'ResolvePackageSources'
DEBUG: 00:00:07.8593775 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:07.8629717 ProviderName: PowerShellGet
DEBUG: 00:00:07.8638433 Verbose: False
DEBUG: 00:00:07.8656218 Name: DevOps_Test
DEBUG: 00:00:07.8679429 ErrorVariable: ev
DEBUG: 00:00:07.8692897 INVOKING PowerShell Fn Resolve-PackageSource with args that has length 0
DEBUG: 00:00:07.8712195 In PowerShellGet Provider - 'Resolve-PackageSource'.
DEBUG: 00:00:07.8745581 Yielding package source for DevOps_Test at location https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2
DEBUG: 00:00:07.8755606 Done calling powershell «Resolve-PackageSource» «PSModule»
DEBUG: 00:00:00.0000007 Calling New() : MethodName = 'ResolvePackageSources'
DEBUG: 00:00:00.0000751 Verbose: True
DEBUG: 00:00:00.0001250 Debug: True
DEBUG: 00:00:00.0001713 Credential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.0002162 Source: DevOps_Test
DEBUG: 00:00:00.0018751 INVOKING PowerShell Fn Resolve-PackageSource with args that has length 0
DEBUG: 00:00:00.0040876 In PowerShellGet Provider - 'Resolve-PackageSource'.
DEBUG: 00:00:00.0091445 Yielding package source for DevOps_Test at location https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2
DEBUG: 00:00:00.0112231 Done calling powershell «Resolve-PackageSource» «PSModule»
DEBUG: 00:00:00.0210510 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0211185 Verbose: True
DEBUG: 00:00:00.0211644 Debug: True
DEBUG: 00:00:00.0212104 Credential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.0212552 Source: DevOps_Test
DEBUG: 00:00:00.0229028 INVOKING PowerShell Fn Get-DynamicOptions with args Provider that has length 1
DEBUG: 00:00:00.0250092 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0288087 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0390987 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0391796 Verbose: True
DEBUG: 00:00:00.0392504 Debug: True
DEBUG: 00:00:00.0392960 Credential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.0393667 Source: DevOps_Test
DEBUG: 00:00:00.0410588 INVOKING PowerShell Fn Get-DynamicOptions with args Source that has length 1
DEBUG: 00:00:00.0433624 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0496191 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0676285 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0676937 Verbose: True
DEBUG: 00:00:00.0677411 Debug: True
DEBUG: 00:00:00.0677874 Credential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.0678323 Source: DevOps_Test
DEBUG: 00:00:00.0695175 INVOKING PowerShell Fn Get-DynamicOptions with args Package that has length 1
DEBUG: 00:00:00.0716406 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0842200 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:02.8587638 Calling New() : MethodName = 'ResolvePackageSources'
DEBUG: 00:00:02.8600843 ProviderName: PowerShellGet
DEBUG: 00:00:02.8609992 Type: Module
DEBUG: 00:00:02.8620491 Source: DevOps_Test
DEBUG: 00:00:02.8626745 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:02.8639089 Debug: True
DEBUG: 00:00:02.8651601 Verbose: True
DEBUG: 00:00:02.8658895 Credential: System.Management.Automation.PSCredential
DEBUG: 00:00:02.8671133 INVOKING PowerShell Fn Resolve-PackageSource with args that has length 0
DEBUG: 00:00:02.8711579 In PowerShellGet Provider - 'Resolve-PackageSource'.
VERBOSE: Repository details, Name = 'DevOps_Test', Location = 'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2'; IsTrusted = 'True'; IsRegistered = 'True'.
DEBUG: 00:00:02.8764245 Yielding package source for DevOps_Test at location https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2
DEBUG: 00:00:02.8784605 Done calling powershell «Resolve-PackageSource» «PSModule»
DEBUG: 00:00:02.8787701 Calling SearchForPackages. Name=''
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
DEBUG: 00:00:02.8801420 PackageProvider::FindPackage with name
DEBUG: 00:00:02.8805756 Calling SearchForPackages After Select 1
DEBUG: 00:00:02.8859541 Calling New() : MethodName = 'FindPackage'
DEBUG: 00:00:02.8874245 ProviderName: PowerShellGet
DEBUG: 00:00:02.8884025 Type: Module
DEBUG: 00:00:02.8932002 Source: DevOps_Test
DEBUG: 00:00:02.8940779 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:02.8950946 Debug: True
DEBUG: 00:00:02.8962040 Verbose: True
DEBUG: 00:00:02.8978720 Credential: System.Management.Automation.PSCredential
DEBUG: 00:00:02.8987789 INVOKING PowerShell Fn Find-Package with args System.String[], , , that has length 4
DEBUG: 00:00:02.9002927 In PowerShellGet Provider - 'Find-Package'.
DEBUG: 00:00:02.9036477 OPTION: ProviderName => PowerShellGet
DEBUG: 00:00:02.9046917 OPTION: Type => Module
DEBUG: 00:00:02.9058328 OPTION: Source => DevOps_Test
DEBUG: 00:00:02.9087662 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:02.9101808 OPTION: Debug => True
DEBUG: 00:00:02.9113463 OPTION: Verbose => True
DEBUG: 00:00:02.9150364 OPTION: Credential => System.Management.Automation.PSCredential
VERBOSE: Using the specified source names : 'DevOps_Test'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2' and PackageManagementProvider is 'NuGet'.
DEBUG: 00:00:02.9228582 PackageProvider::FindPackage with name
DEBUG: 00:00:02.9302698 Calling 'NuGet'::'FindPackage' - name='', requiredVersion='',minimumVersion='', maximumVersion='''.
DEBUG: 00:00:02.9319072 Iterating ''.
VERBOSE: Total package yield:'0' for the specified package ''.
DEBUG: 00:00:02.9345263 Completed iterating for ''.
DEBUG: 00:00:02.9381165 Iterating ''.
DEBUG: 00:00:02.9411334 There are '1' registered sources in 'NuGet' provider.
DEBUG: 00:00:02.9429579 Source 'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2' is not one of the registered sources in 'NuGet' provider.
WARNING: Unable to resolve package source 'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2'.
VERBOSE: Total package yield:'0' for the specified package ''.
DEBUG: 00:00:03.8329293 Completed iterating for ''.
DEBUG: 00:00:03.8348559 PowerShell Script 'PSModule' Function 'Find-Package' returns null.
DEBUG: 00:00:03.8367784 Done calling powershell «Find-Package» «PSModule»
From a combination of PackageManagement version 1.1.7.2 and PowerShellGet 2.0.3, I’ve done the following:
PS C:\Register-PSRepository -Credential $c -Name 'DevOps_Test' -InstallationPolicy 'Trusted' -SourceLocation 'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2' -PackageManagementProvider 'Nuget' -Verbose -Debug
PS C:\Find-Module -Credential $c -Repository 'DevOps_Test' -Verbose -Debug
DEBUG: 00:00:00.0000003 Calling New() : MethodName = 'ResolvePackageSources'
DEBUG: 00:00:00.0000809 Verbose: False
DEBUG: 00:00:00.0001294 Name: DevOps_Test
DEBUG: 00:00:00.0001735 ErrorVariable: ev
DEBUG: 00:00:00.0833225 INVOKING PowerShell Fn Resolve-PackageSource with args that has length 0
DEBUG: 00:00:00.0850773 In PowerShellGet Provider - 'Resolve-PackageSource'.
DEBUG: 00:00:00.0865695 Yielding package source for DevOps_Test at location https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2
DEBUG: 00:00:00.0871519 Done calling powershell «Resolve-PackageSource» «PSModule»
DEBUG: 00:00:00.0920287 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0920557 Verbose: False
DEBUG: 00:00:00.0920757 Name: DevOps_Test
DEBUG: 00:00:00.0920951 ErrorVariable: ev
DEBUG: 00:00:00.0927234 INVOKING PowerShell Fn Get-DynamicOptions with args Provider that has length 1
DEBUG: 00:00:00.0934972 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0946594 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0993681 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0993951 Verbose: False
DEBUG: 00:00:00.0994155 Name: DevOps_Test
DEBUG: 00:00:00.0994345 ErrorVariable: ev
DEBUG: 00:00:00.1000183 INVOKING PowerShell Fn Get-DynamicOptions with args Source that has length 1
DEBUG: 00:00:00.1006995 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.1024135 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.7829611 Calling New() : MethodName = 'ResolvePackageSources'
DEBUG: 00:00:00.7840074 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:00.7853191 ProviderName: PowerShellGet
DEBUG: 00:00:00.7870247 Verbose: False
DEBUG: 00:00:00.7887014 Name: DevOps_Test
DEBUG: 00:00:00.7893885 ErrorVariable: ev
DEBUG: 00:00:00.7901758 INVOKING PowerShell Fn Resolve-PackageSource with args that has length 0
DEBUG: 00:00:00.7913482 In PowerShellGet Provider - 'Resolve-PackageSource'.
DEBUG: 00:00:00.7936967 Yielding package source for DevOps_Test at location https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2
DEBUG: 00:00:00.7947477 Done calling powershell «Resolve-PackageSource» «PSModule»
DEBUG: 00:00:00.7984645 Calling New() : MethodName = 'ResolvePackageSources'
DEBUG: 00:00:00.8010489 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:00.8022220 ProviderName: PowerShellGet
DEBUG: 00:00:00.8032391 Verbose: False
DEBUG: 00:00:00.8041176 Name: DevOps_Test
DEBUG: 00:00:00.8060135 ErrorVariable: ev
DEBUG: 00:00:00.8071407 INVOKING PowerShell Fn Resolve-PackageSource with args that has length 0
DEBUG: 00:00:00.8090283 In PowerShellGet Provider - 'Resolve-PackageSource'.
DEBUG: 00:00:00.8115522 Yielding package source for DevOps_Test at location https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2
DEBUG: 00:00:00.8126699 Done calling powershell «Resolve-PackageSource» «PSModule»
DEBUG: 00:00:00.0000003 Calling New() : MethodName = 'ResolvePackageSources'
DEBUG: 00:00:00.0000900 Verbose: True
DEBUG: 00:00:00.0001429 Debug: True
DEBUG: 00:00:00.0001910 Credential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.0002359 Source: DevOps_Test
DEBUG: 00:00:00.0018153 INVOKING PowerShell Fn Resolve-PackageSource with args that has length 0
DEBUG: 00:00:00.0038002 In PowerShellGet Provider - 'Resolve-PackageSource'.
DEBUG: 00:00:00.0096178 Yielding package source for DevOps_Test at location https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2
DEBUG: 00:00:00.0113920 Done calling powershell «Resolve-PackageSource» «PSModule»
DEBUG: 00:00:00.0204971 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0205430 Verbose: True
DEBUG: 00:00:00.0205737 Debug: True
DEBUG: 00:00:00.0206039 Credential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.0206335 Source: DevOps_Test
DEBUG: 00:00:00.0219051 INVOKING PowerShell Fn Get-DynamicOptions with args Provider that has length 1
DEBUG: 00:00:00.0233474 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0255817 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0344732 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0345187 Verbose: True
DEBUG: 00:00:00.0345494 Debug: True
DEBUG: 00:00:00.0345793 Credential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.0346088 Source: DevOps_Test
DEBUG: 00:00:00.0357856 INVOKING PowerShell Fn Get-DynamicOptions with args Source that has length 1
DEBUG: 00:00:00.0367214 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0387748 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0425631 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0425827 Verbose: True
DEBUG: 00:00:00.0425948 Debug: True
DEBUG: 00:00:00.0426068 Credential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.0426189 Source: DevOps_Test
DEBUG: 00:00:00.0432249 INVOKING PowerShell Fn Get-DynamicOptions with args Package that has length 1
DEBUG: 00:00:00.0439426 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0468075 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.1152357 Calling New() : MethodName = 'ResolvePackageSources'
DEBUG: 00:00:00.1201544 ProviderName: PowerShellGet
DEBUG: 00:00:00.1210668 Type: Module
DEBUG: 00:00:00.1221072 Source: DevOps_Test
DEBUG: 00:00:00.1231673 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:00.1245626 Debug: True
DEBUG: 00:00:00.1254929 Verbose: True
DEBUG: 00:00:00.1271499 Credential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.1309702 INVOKING PowerShell Fn Resolve-PackageSource with args that has length 0
DEBUG: 00:00:00.1332994 In PowerShellGet Provider - 'Resolve-PackageSource'.
VERBOSE: Repository details, Name = 'DevOps_Test', Location = 'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2'; IsTrusted = 'True'; IsRegistered = 'True'.
DEBUG: 00:00:00.1373101 Yielding package source for DevOps_Test at location https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2
DEBUG: 00:00:00.1386510 Done calling powershell «Resolve-PackageSource» «PSModule»
DEBUG: 00:00:00.1387465 Calling SearchForPackages. Name=''
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
DEBUG: 00:00:00.1397847 PackageProvider::FindPackage with name
DEBUG: 00:00:00.1407967 Calling SearchForPackages After Select 1
DEBUG: 00:00:00.1473130 Calling New() : MethodName = 'FindPackage'
DEBUG: 00:00:00.1497049 ProviderName: PowerShellGet
DEBUG: 00:00:00.1538002 Type: Module
DEBUG: 00:00:00.1546112 Source: DevOps_Test
DEBUG: 00:00:00.1555696 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:00.1567106 Debug: True
DEBUG: 00:00:00.1576442 Verbose: True
DEBUG: 00:00:00.1586813 Credential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.1596999 INVOKING PowerShell Fn Find-Package with args System.String[], , , that has length 4
DEBUG: 00:00:00.1612307 In PowerShellGet Provider - 'Find-Package'.
DEBUG: 00:00:00.1647604 OPTION: ProviderName => PowerShellGet
DEBUG: 00:00:00.1660743 OPTION: Type => Module
DEBUG: 00:00:00.1678470 OPTION: Source => DevOps_Test
DEBUG: 00:00:00.1692400 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:00.1705901 OPTION: Debug => True
DEBUG: 00:00:00.1719102 OPTION: Verbose => True
DEBUG: 00:00:00.1752199 OPTION: Credential => System.Management.Automation.PSCredential
VERBOSE: Using the specified source names : 'DevOps_Test'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2' and PackageManagementProvider is 'NuGet'.
DEBUG: 00:00:00.1852364 PackageProvider::FindPackage with name
DEBUG: 00:00:00.1883434 Calling 'NuGet'::'FindPackage' - name='', requiredVersion='',minimumVersion='', maximumVersion='''.
DEBUG: 00:00:00.1894524 Iterating ''.
VERBOSE: Total package yield:'0' for the specified package ''.
DEBUG: 00:00:00.1917458 Completed iterating for ''.
DEBUG: 00:00:00.1936235 Iterating ''.
DEBUG: 00:00:00.1972126 There are '1' registered sources in 'NuGet' provider.
DEBUG: 00:00:00.1990156 Source 'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2' is not one of the registered sources in 'NuGet' provider.
DEBUG: 00:00:02.2199459 Source 'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2' is validated.
DEBUG: 00:00:02.2287251 Calling 'NuGetRequest'::'SearchForPackages', ''.
VERBOSE: Searching repository 'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2/' for ''.
DEBUG: 00:00:02.3894056 Calling 'HttpClientPackageRepository'::'Search', ''.
DEBUG: 00:00:02.3946973 Downloading 'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2/Search()?$filter=IsLatestVersion&searchTerm=''&targetFramework=''&includePrerelease=false&$skip=0&$top=40'.
DEBUG: 00:00:02.7842284 Completed downloading
'https://pkgs.dev.azure.com/osisoft/_packaging/DevOps_Test/nuget/v2/Search()?$filter=IsLatestVersion&searchTerm=''&targetFramework=''&includePrerelease=false&$skip=0&$top=40'.
DEBUG: 00:00:02.7908450 '5' packages received in the last request.
VERBOSE: Total package yield:'5' for the specified package ''.
DEBUG: 00:00:02.8519433 Completed iterating for ''.
DEBUG: 00:00:02.9110294 Done calling powershell «Find-Package» «PSModule»
Version Name Repository Description
------- ---- ---------- -----------
0.1.5 DSCTestHelper DevOps_Test Module that provides functions to test DSC module/resources
0.1.0 HelloWorld DevOps_Test Do nothing
0.1.10 OSIDSCPushConfigurations DevOps_Test Installation and configuration of machines via DSC push model using local or remote connection
5.5.0.0 xNetworking DevOps_Test Module with DSC Resources for Networking area
0.1.23 xOSIDSC DevOps_Test OSIsoft Desired State Configuration (DSC) Resource Kit, which is a collection of DSC Resources produced by the DevOps Team. This module co...
After some digging and comparisons of the source code around the version 1.2.3 and 1.1.7.2, something caught my eyes, one aspect has changed within the SelectedSources property definition (at src\Microsoft.PackageManagement.NuGetProvider\NugetLightRequest.cs). It is the validation of unregistered sources that has changed.
With version 1.1.7.2, the validation was done with: NuGetPathUtility.ValidateSourceUri(SupportedSchemes, srcUri, this);
but now (version 1.2.3) it is done with: ConcurrentInMemoryCache.Instance.GetOrAdd(String.Format(CultureInfo.InvariantCulture, "SelectedSources:{0}", srcUri.AbsoluteUri), () => NuGetPathUtility.ValidateSourceUri(SupportedSchemes, srcUri, this));
I am convinced there is a problem around the handling of the cached data. I’ll let you confirm this or not. As of now, the only workaround for me is to use version 1.1.7.2 of PackageManagement if you want to use a privately hosted feed on Azure DevOps artifact service. Will this be investigated and addressed?
Sincerely
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 4
- Comments: 33 (1 by maintainers)
I worked around this by registering a NuGet package source before registering my azure artifacts ps repo:
After the repo is registered the first time it works after the shell is restarted but in a script i needed this.
Hi all,
Is there an estimated “fix” date for this, or/and a suitable workaround?
I’m wanting to register a PSRepository on the (hosted) Azure DevOps build server(s) as part of the build process so I can use “Find-Module” and “Install-Module” in order to find/install/use my own PSModules hosted in my own, private PSRepositories. These PSRespositories are currently hosted within Azure DevOps “Artifacts” (formerly, VSTS Package Management) and I see an identical error to the above.
I can connect to the same artifact repository from my laptop using PackageManagement v1.1.4.0.
I’ve also been trying to remove the latest version of ‘PackageManagement’ and install/import an older version with little success at at present. I’d expect the process for this to be quite straightforward, but despite
Get-Moduleshowing I’ve successfully removed the more recent version and replaced it with an older one, I’m not sure if some of the PowerShell commands are re-installing/re-importing the newer version, or if the cmdlets I’m using/calling are from a cached version of the cmdlets within the session.Running
Get-Moduleshows the (Hosted) AzureDevOps, VS2017 PSModule image (as of today) contains the following PSModule versions:Please shout if you’ve any questions.
Cheers,
Paul
I got tired of this hacky workaround and just decided to use nuget directly to download the package. This also works with an powershell environment which is started in
-NoProfilemode. Use$psFolderinstead of$psCoreFolderif you’re not using PowerShell Core.This was to install a specific version but you get the idea, nuget can be used instead of Find-Module as well.
I think it’s because there’s a trailing
/in his-SourceLocationvalue.I’m making a comment here for both myself and future viewers, you specifically have to register a new package source with provider NuGet, before registering a new PS repository (which itself will register a new package source with provider PowerShellGet). For some reason, authentication only works if you have your package source listed twice, once with each provider.
If I unregistered the package source with the NuGet provider in the end, I was no longer able to get modules.
I verified this with both PowerShell 5 and PowerShell Core, using version 2.1.2 of the PowerShellGet module and version 1.3.1 of the PackageManagement module.
This is exactly what @krokofant posted, credit goes to them. I’m just clarifying that the provider in your registrations is what’s important here.
Ran into this today as well, the @krokofant solution worked for me too.