PowerShell / PowerShell

PowerShell for every system!
https://microsoft.com/PowerShell
MIT License
45.13k stars 7.28k forks source link

Cannot install module from Azure DevOps feed #20387

Closed Agazoth closed 1 year ago

Agazoth commented 1 year ago

Prerequisites

Steps to reproduce

Follow this guide: https://learn.microsoft.com/en-us/azure/devops/artifacts/tutorials/private-powershell-library?view=azure-devops

Expected behavior

Installs my module

Actual behavior

Install-Package: Cannot find the path 'C:\Users\Me\AppData\Local\Temp\1414719836\MyModule.0.0.2\MyModule.psd1' because it does not exist.

Error details

Exception             :
    Type    : System.Exception
    Message : Cannot find the path 'C:\Users\Me\AppData\Local\Temp\1414719836\MyModule.0.0.2\MyModule.psd1' because it does not ex
ist.
    HResult : -2146233088
TargetObject          : Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
CategoryInfo          : InvalidOperation: (Microsoft.PowerShel…lets.InstallPackage:InstallPackage) [Install-Package], Exceptio
n
FullyQualifiedErrorId : PathNotFound,Test-ValidManifestModule,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
InvocationInfo        :
    MyCommand        : Install-Package
    ScriptLineNumber : 9711
    OffsetInLine     : 34
    HistoryId        : 292
    ScriptName       : C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1
    Line             : $installedPackages = PackageManagement\Install-Package @PSBoundParameters

    PositionMessage  : At C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9711 char:34
                       + … talledPackages = PackageManagement\Install-Package @PSBoundParameters
                       +                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : C:\program files\powershell\7\Modules\PowerShellGet
    PSCommandPath    : C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1
    InvocationName   : PackageManagement\Install-Package
    CommandOrigin    : Internal
ScriptStackTrace      : at Install-Module<Process>, C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1: line 97
11
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.7
PSEdition                      Core
GitCommitId                    7.3.7
OS                             Microsoft Windows 10.0.22621
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

prayaas-a commented 1 year ago

I believe this is because PowerShellGet (which is internally used by PowerShell) is incompatible with NuGet v3 feeds, which is what Azure Artifacts uses (as it should - v2 is deprecated).

PowerShellGet is being replaced by Microsoft.PowerShell.PSResourceGet which I believe does support NuGet v3 repositories, but hasn't been released yet (it's in RC). Can owners here confirm if that module will, in fact, make it to PowerShell 7.4? It may even be possible to bring it downlevel to supported 7.x using v3 of PowerShellGet (the compatibility pack).

SteveL-MSFT commented 1 year ago

Install-Package is part of OneGet (aka PackageManagement) and not part of PS7. PSResourceGet added support for nuget v3.

Agazoth commented 1 year ago

I see! Guess I'll try this tomorrow: https://devblogs.microsoft.com/powershell/psresourceget-preview-is-now-available/

Updating this issue with the results after upgrade.

PowerShell Team
PSResourceGet Preview is Now Available - PowerShell Team
Microsoft.PowerShell.PSResourceGet is a continuation of the PowerShellGet 3.0 project. The first preview release of this module under the new name is now available on the PowerShell Gallery. This release contains the module rename, and reintroduces support for Azure Artifacts, GitHub packages,
Agazoth commented 1 year ago

I can confirm that PSResourceGet works. I just followed the instructions in the link above. Closing this issue