Open csandfeld opened 6 years ago
Ahh that's a pain. IIRC did this to avoid odd folder names:
ExcludeVersion | Installs the package to a folder named with only the package name and not the version number.
Wonder if anything changed in nuget that broke this? Will poke around
edit: yeah, without that switch we end up with unexpected folder names like poshbot.0.10.0
in the target
Hi again!
Would you mind running with -verbose
and including sanitized output? Curious to see what path it's following. Wonder if there are API differences with MyGet
My guess is MyGet doesn't understand -version latest
. Seems to line up with the error, and would explain why it happens when not specifying a version (latest
is used in that case).
What really puzzled me was that even when running nuget.exe
manually, trying to get TestMod99
downloaded, it would still complain about psdepend
in the message. I even tried moving nuget.exe
to a different folder. Guess this is a NuGet thing.
I will run with -verbose and post output later today :)
build_psdepend.ps1:
$tempPath = Join-Path -Path $PSScriptRoot -ChildPath 'temp'
$tempModulePath = Join-Path -Path $tempPath -ChildPath 'modules'
$installPSDependPath = Join-Path -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'build') -ChildPath 'helpers') -ChildPath 'Install-PSDepend.ps1'
### Getting dependencies
# Get PSDepened
& "$installPSDependPath" "$tempModulePath" -Verbose
Remove-Module -Name 'PSDepend' -Force -ErrorAction SilentlyContinue
Import-Module ('{0}\temp\modules\psdepend\PSDepend.psd1' -f $PSScriptRoot) -Force -Verbose
Invoke-PSDepend -Path "$PSScriptRoot\build\build.requirements.psd1" -Target $tempModulePath -Force -Install -Verbose
build.requirements.psd1 (sanitized):
@{
'TestMod99' = @{
DependencyType = 'PSGalleryNuget'
Source = 'https://some.myget.feed/.../api/v2/'
}
}
Verbose output (sanitized):
D:\Some\Custom\Path> D:\Some\Custom\Path\build_psdepend.ps1
VERBOSE: GET https://dist.nuget.org/win-x86-commandline/latest/nuget.exe with 0-byte payload
VERBOSE: received 5066856-byte response of content type application/x-msdownload
Feeds used:
https://www.powershellgallery.com/api/v2/
Installing package 'PSDepend' to 'D:\Some\Custom\Path\temp\modules'.
GET https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PSDepend'&semVerLevel=2.0.0
OK https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PSDepend'&semVerLevel=2.0.0 150ms
GET https://www.powershellgallery.com/api/v2/FindPackagesById?id='PSDepend'&$skiptoken='PSDepend','0.1.60'
OK https://www.powershellgallery.com/api/v2/FindPackagesById?id='PSDepend'&$skiptoken='PSDepend','0.1.60' 118ms
Attempting to gather dependency information for package 'PSDepend.0.1.63' with respect to project 'D:\Some\Custom\Path\temp\modules', targeting 'Any,Version=v0.0'
Gathering dependency information took 42,4 ms
Attempting to resolve dependencies for package 'PSDepend.0.1.63' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'PSDepend.0.1.63'
Resolved actions to install package 'PSDepend.0.1.63'
Retrieving package 'PSDepend 0.1.63' from 'https://www.powershellgallery.com/api/v2/'.
Adding package 'psdepend.0.1.63' to folder 'D:\Some\Custom\Path\temp\modules'
Added package 'psdepend.0.1.63' to folder 'D:\Some\Custom\Path\temp\modules'
Successfully installed 'PSDepend 0.1.63' to D:\Some\Custom\Path\temp\modules
Executing nuget actions took 260,1 ms
VERBOSE: Loading module from path 'D:\Some\Custom\Path\temp\modules\psdepend\PSDepend.psd1'.
VERBOSE: Loading 'FormatsToProcess' from path 'D:\Some\Custom\Path\temp\modules\psdepend\PSDepend.Format.ps1xml'.
VERBOSE: Loading module from path 'D:\Some\Custom\Path\temp\modules\psdepend\PSDepend.psm1'.
VERBOSE: Importing function 'Get-Dependency'.
VERBOSE: Importing function 'Get-PSDependScript'.
VERBOSE: Importing function 'Get-PSDependType'.
VERBOSE: Importing function 'Import-Dependency'.
VERBOSE: Importing function 'Install-Dependency'.
VERBOSE: Importing function 'Invoke-DependencyScript'.
VERBOSE: Importing function 'Invoke-PSDepend'.
VERBOSE: Importing function 'Test-Dependency'.
VERBOSE: Running Invoke-PSDepend with ParameterSetName 'installimport-file', PSDependAction Install, and params:
Key Value
--- -----
Path {D:\Some\Custom\Path\build\build.requirements.psd1}
Target D:\Some\Custom\Path\temp\modules
Force True
Install True
Verbose True
VERBOSE: Working with [1] dependency files from [D:\Some\Custom\Path\build\build.requirements.psd1]:
D:\Some\Custom\Path\build\build.requirements.psd1
VERBOSE: Overriding Dependency target [] with target parameter value [D:\Some\Custom\Path\temp\modules]
VERBOSE: Running Invoke-DependencyScript with ParameterSetName 'Map' and params:
Key Value
--- -----
PSDependAction {Install}
PSDependTypePath D:\Some\Custom\Path\temp\modules\psdepend\PSDependMap.psd1
Dependency @{DependencyFile=D:\Some\Custom\Path\build\build.requirements.psd1; DependencyName=TestMod99; DependencyType=PSGalleryNuget; Name=; Version=; Parameters=; Source=h...
VERBOSE: Dependencies:
DependencyFile : D:\Some\Custom\Path\build\build.requirements.psd1
DependencyName : TestMod99
DependencyType : PSGalleryNuget
Name :
Version :
Parameters :
Source : https://some.myget.feed/.../api/v2/
Target : D:\Some\Custom\Path\temp\modules
AddToPath :
Tags :
DependsOn :
PreScripts :
PostScripts :
PSDependOptions :
Raw : {Source, DependencyType}
VERBOSE: Searching for D:\Some\Custom\Path\temp\modules\psdepend\PSDependScripts\PSGalleryNuget.ps1
VERBOSE: Searching for PSGalleryNuget.ps1
VERBOSE: Get-Parameters for D:\Some\Custom\Path\temp\modules\psdepend\PSDependScripts\PSGalleryNuget.ps1\PSGalleryNuget.ps1
VERBOSE: Found parameters [Dependency Force Import PSDependAction]
VERBOSE: Invoking 'D:\Some\Custom\Path\temp\modules\psdepend\PSDependScripts\PSGalleryNuget.ps1' with parameters
Name Value
---- -----
Dependency @{DependencyFile=D:\Some\Custom\Path\build\build.requirements.psd1; DependencyName=TestMod99; DependencyType=PSGalleryNuget; Name=; Version=; Paramet...
PSDependAction {Install}
VERBOSE: Getting dependency [TestMod99] from Nuget source [https://some.myget.feed/.../api/v2/]
VERBOSE: Saving [TestMod99] with path [D:\Some\Custom\Path\temp\modules]
VERBOSE: Running nuget.exe with arguments install; TestMod99; -Source; https://some.myget.feed/.../api/v2/; -ExcludeVersion; -NonInteractive; -OutputDirectory; D:\Some\Custom\Path\temp\modules
Unable to find package 'psdepend'. Existing packages must be restored before performing an install or update.
VERBOSE: Feeds used:
https://some.myget.feed/.../api/v2/
Installing package 'TestMod99' to 'D:\Some\Custom\Path\temp\modules'.
GET https://some.myget.feed/.../api/v2/FindPackagesById()?id='TestMod99'&semVerLevel=2.0.0
OK https://some.myget.feed/.../api/v2/FindPackagesById()?id='TestMod99'&semVerLevel=2.0.0 227ms
Attempting to gather dependency information for package 'TestMod99.0.0.3' with respect to project 'D:\Some\Custom\Path\temp\modules', targeting 'Any,Version=v0.0'
Gathering dependency information took 749,39 ms
Attempting to resolve dependencies for package 'TestMod99.0.0.3' with DependencyBehavior 'Lowest'
D:\Some\Custom\Path>
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):
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:
NuGet Version:
Windows Version:
PowerShell Version:
Host: