Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Install-Module fails from ADO feed on Powershell 7 #686

Open
3 tasks done
tgrader opened this issue Nov 8, 2022 · 5 comments
Open
3 tasks done

Install-Module fails from ADO feed on Powershell 7 #686

tgrader opened this issue Nov 8, 2022 · 5 comments

Comments

@tgrader
Copy link

tgrader commented Nov 8, 2022

Prerequisites

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

Steps to reproduce

  1. Install latest release of Powershell 7.
  2. Create an ADO feed and register it as a repository following the instructions here: https://learn.microsoft.com/en-us/azure/devops/artifacts/tutorials/private-powershell-library?view=azure-devops
  3. Attempt to install the module as described in article above using PowershellGet 2.2.5

Expected behavior

The module installs successfully.

As in this case, if the module does not contain a .psm1, .psd1, or .dll. The -Force switch should allow this dependency installation to succeed as documented in the article linked below.

https://learn.microsoft.com/en-us/powershell/module/powershellget/install-module?view=powershell-7.2

Actual behavior

the module fails a dependency install stating that the manifest does not exist despite using the -force command.

PS C:\> Install-package -name trgraderrepro -Source PowershellAzureDevopsServicesPSGET -Credential $credsAzureDevopsServices -Provider PowerShellGet -Verbose -force
VERBOSE: Suppressed Verbose Repository details, Name = 'PowershellAzureDevopsServicesPSGet', Location = 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2'; IsTrusted = 'True'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'PowershellAzureDevopsServicesPSGet', Location = 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2'; IsTrusted = 'True'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'PowershellAzureDevopsServicesPSGET'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2/FindPackagesById()?id='trgraderrepro'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'trgraderrepro'.
VERBOSE: Performing the operation "Install Package" on target "Package 'trgraderrepro' version '1.0.0' from 'PowershellAzureDevopsServicesPSGet'.".
VERBOSE: The specified module will be installed in 'C:\Users\trgrader\OneDrive - Microsoft\Documents\PowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'trgraderrepro' with version '1.0.0' from the repository 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2'.
VERBOSE: Searching repository 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2/FindPackagesById()?id='trgraderrepro'' for ''.
VERBOSE: Searching repository 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2/FindPackagesById()?id='SampleDependency'' for ''.
VERBOSE: Searching repository 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2/FindPackagesById()?id='jQuery'' for ''.
VERBOSE: InstallPackage' - name='jQuery', version='3.6.1',destination='C:\Users\trgrader\AppData\Local\Temp\1142624899' 
VERBOSE: DownloadPackage' - name='jQuery', version='3.6.1',destination='C:\Users\trgrader\AppData\Local\Temp\1142624899\jQuery.3.6.1\jQuery.3.6.1.nupkg', uri='https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2?id=jquery&version=3.6.1'
VERBOSE: Downloading 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2?id=jquery&version=3.6.1'.          
VERBOSE: Completed downloading 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2?id=jquery&version=3.6.1'.
VERBOSE: Completed downloading 'jQuery'.                                                                                
VERBOSE: Hash not found for the package 'jQuery'.                                                                       
VERBOSE: InstallPackageLocal' - name='jQuery', version='3.6.1',destination='C:\Users\trgrader\AppData\Local\Temp\1142624899'
VERBOSE: InstallPackage' - name='SampleDependency', version='1.0.0',destination='C:\Users\trgrader\AppData\Local\Temp\1142624899'
VERBOSE: DownloadPackage' - name='SampleDependency', version='1.0.0',destination='C:\Users\trgrader\AppData\Local\Temp\1142624899\SampleDependency.1.0.0\SampleDependency.1.0.0.nupkg', uri='https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2?id=sampledependency&version=1.0.0'
VERBOSE: Downloading 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2?id=sampledependency&version=1.0.0'.
VERBOSE: Completed downloading 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2?id=sampledependency&version=1.0.0'.
VERBOSE: Completed downloading 'SampleDependency'.                                                                      
VERBOSE: Hash not found for the package 'SampleDependency'.                                                             
VERBOSE: InstallPackageLocal' - name='SampleDependency', version='1.0.0',destination='C:\Users\trgrader\AppData\Local\Temp\1142624899'
VERBOSE: InstallPackage' - name='trgraderrepro', version='1.0.0',destination='C:\Users\trgrader\AppData\Local\Temp\1142624899'
VERBOSE: DownloadPackage' - name='trgraderrepro', version='1.0.0',destination='C:\Users\trgrader\AppData\Local\Temp\1142624899\trgraderrepro.1.0.0\trgraderrepro.1.0.0.nupkg', uri='https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2?id=trgraderrepro&version=1.0.0'
VERBOSE: Downloading 'https://pkgs.dev.azure.com/trgrader/_packaging/repro2/nuget/v2?id=trgraderrepro&version=1.0.0'.   
VERBOSE: Validating the 'jQuery' module contents under 'C:\Users\trgrader\AppData\Local\Temp\1142624899\jQuery.3.6.1' path.
Install-Package: Cannot find the path 'C:\Users\trgrader\AppData\Local\Temp\1142624899\jQuery.3.6.1\jQuery.psd1' because it does not exist.

Error details

PS C:\> GET-ERROR                                                                                                       

Exception             : 
    Type    : System.Exception
    Message : Cannot find the path 'C:\Users\trgrader\AppData\Local\Temp\1142624899\jQuery.3.6.1\jQuery.psd1' because it does not exist.
    HResult : -2146233088
TargetObject          : Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
CategoryInfo          : InvalidOperation: (Microsoft.PowerShel…lets.InstallPackage:InstallPackage) [Install-Package], Exception
FullyQualifiedErrorId : PathNotFound,Test-ValidManifestModule,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
InvocationInfo        : 
    MyCommand        : Install-Package
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 7
    Line             : Install-package -name trgraderrepro -Source PowershellAzureDevopsServicesPSGET -Credential $credsAzureDevopsServices -Provider PowerShellGet        
-Verbose -force
    PositionMessage  : At line:1 char:1
                       + Install-package -name trgraderrepro -Source PowershellAzureDevopsServ …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Install-package
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :

Environment data

PS C:\> $psversiontable

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

Directory: C:\program files\powershell\7\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.4.7                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource…}
Script     2.2.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability…}

Version

2.2.5

Visuals

No response

@anamnavi
Copy link
Member

@tgrader thanks for reaching out! I noticed that you are using Install-Package (which comes from PackageManagement). Could you use Install-Module (which comes from PowerShellGet V2).

Also, are the packages jQuery and sampleDependency published to the ADO feed?

@travisgr
Copy link

Hello, Please find the results you've requested below.

PS C:\Users\trgrader> Find-Module -Repository PowershellAzureDevopsServices -Credential $credsAzureDevopsServices

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
3.6.1                jQuery                              PowershellAzureDevo… jQuery is a new kind of JavaScript Libra…
1.0.0                SampleDependency                    PowershellAzureDevo… Sample forom PluralSight
1.0.0                trgraderrepro                       PowershellAzureDevo… Package description

PS C:\Users\trgrader> Install-Module -Name jquery -Repository PowershellAzureDevopsServices -Credential $credsAzureDevopsServices

Install-Package: Cannot find the path 'C:\Users\trgrader\AppData\Local\Temp\489951973\jQuery.3.6.1\jQuery.psd1' because it does not exist.

The problem is in Install-PackageUtility.ps1. This function calls a module-internal command named "Test-ValidModuleManifest" which triggers this error to be returned and does not honor the -Force parameter.

$CurrentModuleInfo = Test-ValidManifestModule -ModuleBasePath $sourceModulePath `

@alerickson
Copy link
Member

@travisgr PowerShellGet was originally really only meant to interact with PowerShell modules/scripts (hence why it's expecting to find a .psd1). We're working on a rewrite of PowerShellGet that better abstracts modules so that users have a better experience with generic .nupkgs and not just specifically PowerShell packages.

Could you try using the latest prerelease version and if there's anything you'd like to see improved or any new features you think would be nice to have we can address those changes there.

@travisgr
Copy link

The latest version also fails to install this package. It's checking for the existence of a .ps1.

PS C:\Users\trgrader> Get-PSResource

Name          Version Prerelease Repository Description
----          ------- ---------- ---------- -----------
PowerShellGet 3.0.17  beta17     PSGallery  PowerShell module with commands for discovering, installing, updating and …

Install-PSResource: Unable to successfully install package 'jQuery': 'Could not find file 'C:\Users\trgrader\AppData\Local\Temp\e587a46a-4d4a-410f-a4ba-509babc8b2c8\jquery\3.6.1\jQuery.ps1'.'
PS C:\Users\trgrader> Install-PSResource -Name Jquery -Repository PowershellAzureDevopsServices-psgetv3 -Credential $credsAzureDevopsServices -TrustRepository -Verbose
VERBOSE: All paths to search: 'C:\Users\trgrader\Documents\PowerShell\Modules'
VERBOSE: All paths to search: 'C:\Users\trgrader\Documents\PowerShell\Scripts'
VERBOSE: Performing the operation "Install-PSResource" on target "package to install: 'Jquery'".
VERBOSE: Parameters passed in >>> Name: 'Jquery'; Version: ''; Prerelease: 'False'; Repository: 'PowershellAzureDevopsServices-psgetv3'; AcceptLicense: 'False'; Quiet: 'False'; Reinstall: 'False'; TrustRepository: 'True'; NoClobber: 'False'; AsNupkg: 'False'; IncludeXml 'True'; SavePackage 'False'; TemporaryPath ''
VERBOSE: Attempting to search for packages in 'PowershellAzureDevopsServices-psgetv3'
VERBOSE: Untrusted repository accepted as trusted source.
VERBOSE: Searching in repository PowershellAzureDevopsServices-psgetv3
VERBOSE: credential successfully set for repository: PowershellAzureDevopsServices-psgetv3
VERBOSE: Begin installing package: 'jQuery'
VERBOSE: Successfully able to download package from source to: 'C:\Users\trgrader\AppData\Local\Temp\e84450de-4e24-4e4c-9c88-f6ccb236640a'
Install-PSResource: Unable to successfully install package 'jQuery': 'Could not find file 'C:\Users\trgrader\AppData\Local\Temp\e84450de-4e24-4e4c-9c88-f6ccb236640a\jquery\3.6.1\jQuery.ps1'.'
VERBOSE: Attempting to delete 'C:\Users\trgrader\AppData\Local\Temp\e84450de-4e24-4e4c-9c88-f6ccb236640a'
VERBOSE: Successfully deleted 'C:\Users\trgrader\AppData\Local\Temp\e84450de-4e24-4e4c-9c88-f6ccb236640a'

@anamnavi
Copy link
Member

@travisgr thanks for trying this scenario out with PSGet V3. We're working to add better nupkg integration for packages like these which have neither .psd1 nor .ps1 file. These files are always present with PowerShell resources (off powershellgallery site) but we understand that packages from other repositories may not have this and we want to support those packages. The issue to track this work is here: https://github.com/PowerShell/PowerShellGet/issues/310

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants