psget / psget

Set of commands to install PowerShell modules from local file or from the web. Inspired by NuGet
http://psget.net
597 stars 158 forks source link

NugetSource doesn't allow UNC Paths #114

Open GaryRogers opened 10 years ago

GaryRogers commented 10 years ago

Trying to install a NugetPackaged script from a UNC path as the nuget source ex: Install-Module -NugetPackageID MyPackage -NugetSource \mydfs.example.com\shared\nuget -Destination e:\local\my\path\to\powershell\modules

Results in: Install-Module : Unable to download from NuGet feed: Illegal characters in path. At line:1 char:1

chaliy commented 10 years ago

As far I know UNC path should start from "\". Can you please try:

\\mydfs.example.com\shared\nuget
GaryRogers commented 10 years ago

Sorry, typo. I was using the \ path. I also tried putting it in " quotes.

GaryRogers commented 10 years ago

Fun, git hub takes out the leading backslash.

GaryRogers commented 10 years ago

Here's a more verbose error.

PS E:\> Install-Module -NuGetPackageId My-Utils -NugetSource \\mydfs.edu\shared\nuget\ -Destination E:\
local\powershell\modules -Verbose -Update
VERBOSE: Querying '\\mydfs.edu\shared\nuget\/' repository for package with Id 'My-Utils'
Install-Module : Unable to download from NuGet feed: Illegal characters in path.
At line:1 char:1
+ Install-Module -NuGetPackageId My-Utils -NugetSource \\mydfs.edu\shared\nu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-Module
GaryRogers commented 10 years ago

It looks like DownloadNuGetPackage Doesn't allow for UNC paths. It doesn't look like it accepts alternate credentials either... but that's a different issue.

function DownloadNuGetPackage {
    param (
        $NuGetPackageId,
        $PackageVersion,
        $Source,
        $PreRelease,
        $PreReleaseTag
    )

    $WebClient = New-Object -TypeName System.Net.WebClient
    $WebClient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

    if (-not $Source.EndsWith("/"))
    {
        $Source += "/"
    }