i have an interesting issue with Azure Artifacts and sharing a private powershell repository with it.
I followed the guidance provided in this official microsoft documentation: MS doc
I successfully packed and published the module to azure artifacts. But as soons as i try to connect with powershell to the feed i get some problems:
Register-PSRepository and Register-PackageSource are working fine. But Find-Module gives me the first error:
Register-PSRepository -Name "PowershellAzureDevopsServices" -SourceLocation "https://pkgs.dev.azure.com/myorg/myprojectid/_packaging/myfeed/nuget/v2" -PublishLocation "https://pkgs.dev.azure.com/myorg/myprojectid/_packaging/myfeed/nuget/v2" -InstallationPolicy Trusted -Credential $credsAzureDevopsServices
Register-PackageSource -Name "PowershellAzureDevopsServices" -Location "https://pkgs.dev.azure.com/myorg/myprojectid/_packaging/myfeed/nuget/v2" -ProviderName NuGet -Trusted -SkipValidate -Credential $credsAzureDevopsServices
Find-Module -Repository PowershellAzureDevopsServices
WARNUNG: Cannot access
'https://pkgs.dev.azure.com/myorg/myprojectid/_packaging/myfeed/nuget/v2'. Are you
missing 'Credential' parameter in the cmdlet?
WARNUNG: Query Url
I then put the credential parameter to Find-Module and it showed me the modules like expected:
Find-Module -Repository PowershellAzureDevopsServices -Credential $credsAzureDevopsServices
Version Name Repository Description
------- ---- ---------- -----------
0.0.7 Example.Module PowershellAzureDe... Package description
1.0.0 Get-Hello PowershellAzureDe... Package description
But when i try to install the found modules, the next error occures. This error i couldnt solve:
Find-Module -Repository PowershellAzureDevopsServices -Credential $credsAzureDevopsServices | Install-Module -Credential $credsAzureDevopsServices -Scope CurrentUser
PackageManagement\Install-Package : Unable to find dependent module(s) (SampleDependency)
In C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1912 Zeichen:34
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ FullyQualifiedErrorId : UnableToFindDependencyPackage,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPac
kage
PackageManagement\Install-Package : Unable to find dependent module(s) (SampleDependency)
In C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1912 Zeichen:34
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (SampleDependency:String) [Install-Package], Exception
+ FullyQualifiedErrorId : UnableToFindDependencyPackage,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPac
kage
What i also tried so far:
https://pkgs.dev.azure.com/myorg/myprojectid/_packaging/myfeed/nuget/v3/index.json
Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
PowershellAzureDevopsServices NuGet True https://pkgs.dev.azure.com/...
PSGallery PowerShellGet False https://www.powershellgallery.com/api/v2
PowershellAzureDevopsServices PowerShellGet True https://pkgs.dev.azure.com/...
These 2 Providers are also showing up when executing Find-Modules in verbose mode:
Find-Module -Repository PowershellAzureDevopsServices -Credential $credsAzureDevopsServices -Verbose
AUSFÜHRLICH: Repositorydetails, Name = 'PowershellAzureDevopsServices', Location =
'True'; IsRegistered = 'True'.
AUSFÜHRLICH: Using the provider 'PowerShellGet' for searching packages.
AUSFÜHRLICH: Die angegebenen Quellnamen werden verwendet: 'PowershellAzureDevopsServices'.
AUSFÜHRLICH: Das Anbieterobjekt für den PackageManagement-Anbieter "NuGet" wird abgerufen.
AUSFÜHRLICH: Der angegebene Speicherort ist
"https://pkgs.dev.azure.com/myorg/myprojectid/_packaging/myfeed/nuget/v2", und
PackageManagementProvider ist "NuGet".
AUSFÜHRLICH: Total package yield:'0' for the specified package ''.
'https://pkgs.dev.azure.com/myorg/myprojectid/_packaging/myfeed/nuget/v2/' for ''.
AUSFÜHRLICH: Total package yield:'2' for the specified package ''.
But at the end, i have no idea why i cant install the modules ? Maybe you guys have some interesting approches here ?
Some interesting links i found during my research: GitGub MS Dev Community
But unfortunatly none the links helped me in this case.
Thank you in advance for your responses.
i found the issue that lead to that error. First of all, to every one who wants to use azure devops artifacts to publish powershell modules, you can put the documentation to the trash: (https://learn.microsoft.com/en-us/azure/devops/artifacts/tutorials/private-powershell-library?view=azure-devops)
The root cause of the issue when trying to install the module, came from a wrong .nuspec file. When you create the nuspec file like ms says, the file is full with placeholder xml tags and as long as you dont delete these tags you are unable to install the module.
The only necessary tags are:
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>Example.Module2</id>
<version>$VERSIONHERE$</version>
<authors>Jon doe</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<!-- <icon>icon.png</icon> -->
<description>Package description</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
</metadata>
</package>
Every other tags needs to be deleted.
So from the microsoft document, one of the first things you do (create the nuspec file) this default misconfiguration will result in a error at the last step (Install-Module).
Thankfully this guy on reddit explained the problem more detailed: (https://github.com/MicrosoftDocs/azure-devops-docs/issues/12529)