Skip to content

Dependency of type 'PSGalleryNuget' without specifying version throw error #69

@csandfeld

Description

@csandfeld

During testing with PSDepend today I ran into an issue when trying to install a module from a MyGet feed using the 'PSGalleryNuget' dependency type. The module was not installed, and "Unable to find package 'psdepend'. Existing packages must be restored before performing an install or update." was output to the console.

The problem only showed when not specifying a version in the build.requirements.psd1.

Steps to reproduce (on my system atleast):

  • Bootstrap PSDepend to a D:\Some\Custom\Path using the Install-PSDepend.ps1 found in your BuildHelpers repo
  • Import the PSDepend module from D:\Some\Custom\Path\psdepend\PSDepend.psd1
  • Invoke PSDepend (see build.requirements.psd1 below)
    • Invoke-PSDepend -Path "$PSScriptRoot\build\build.requirements.psd1" -Target D:\Some\Custom\Path -Force -Install

Result:
Module is not installed/downloaded, and this output is shown (as standard output):
Unable to find package 'psdepend'. Existing packages must be restored before performing an install or update.

By debugging I found the parameters nuget.exe is called with, and calling nuget.exe directly with those parameters produced the same result:
D:\Some\Custom\Path\psdepend\nuget.exe install TestMod99 -Source "https://some.myget.feed/.../api/v2/" -ExcludeVersion -NonInteractive -OutputDirectory "D:\Some\Custom\Path"

However by trial and error I found that when removing the '-ExcludeVersion' parameter it succeeds:
D:\Some\Custom\Path\psdepend\nuget.exe install TestMod99 -Source "https://some.myget.feed/.../api/v2/" -NonInteractive -OutputDirectory "D:\Some\Custom\Path"

I don't know much about NuGet and it's parameters, so can't really say if it would generally be safe to remove that parameter when no version is specified (or even entirely).

build.requirements.psd1:

@{
    'TestMod99' = @{
        DependencyType = 'PSGalleryNuget'
        Source         = 'https://some.myget.feed/.../api/v2/'
    }
}

NuGet Version:

NuGet Version: 4.5.1.4879

Windows Version:

ProductName           Version Build UBR
-----------           ------- ----- ---
Windows 10 Enterprise 1709    16299 214

PowerShell Version:

Name                           Value
----                           -----
PSVersion                      5.1.16299.98
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.98
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Host:

Name             : Visual Studio Code Host
Version          : 1.5.1
InstanceId       : 30c5f87d-9b2a-4cc6-8d86-0cf9703f8320
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : da-DK
CurrentUICulture : en-US
PrivateData      :
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions