If you’re following me on Twitter then you probably know that I’ve been working a lot with the new features in PowerShell version 5, with my focus being on the cmdlets in the OneGet and PowerShellGet modules.
I’ve been fighting an issue where an error is received when the
Name parameter is specified with
Install-Module when using a local NuGet Repository:
Find-PSGetExtModule : Module ‘Pscx’ was not found in the Gallery. At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PowerShellGet\PSGet.psm1:72 char:13 + Find-PSGetExtModule -Name $Name ` + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : ModuleNotFound,Find-PSGetExtModule
I can also tell you this isn’t an issue that’s specific to a NuGet repository that’s created with ProGet because I started out with a NuGet repository that was created with Visual Studio:
The strange thing is this works without issue with the default online repository:
To confirm that it wasn’t an issue for just me I contacted Tore Groneng via twitter since I knew he had recently written a blog article about setting up an internal PowerShellGet repository with ProGet. He tested the issue I was experiencing and confirmed it was a problem for him as well.
As stated in the error message, I headed to line 72, character 13 of the file:
That led me to the
Find-PSGetExtModule function in the PSGallery module which is located in a
sub-directory of the PowerShellGet module:
I tested the code down to line 298 and determined the problem exists on line 293:
When the code on line 298 is run, the following command is executed in the example where I received the error:
I’m really not sure what the
id: on line 293 does since I couldn’t find it in any of the
NuGet.exe, but simply removing it returns the expected results:
I then removed
id: from line 293 of the PSGallery module (this required some changes to the NTFS
permissions of the file itself):
After re-importing the PowerShellGet module, the
Name parameter worked without issue:
It also still works with the default online repository as well so there must be something where it
id: out somehow that is specific to the online repository:
Note: PowerShell version 5 is currently in preview and shouldn’t be installed in a production environment. Normally the Microsoft supplied modules aren’t script modules so they’re not modifiable and even though this one is, modification of the native modules is definitely not recommended and could lead to unexpected results to say the least.
I verified with Steve Murawski that there is already a Connect Bug for the same issue. Steve also provided me with a link to the NuGet documentation for the “id:” parameter.