OneGet / oneget

PackageManagement (aka OneGet) is a package manager for Windows
MIT License
2.38k stars 190 forks source link

Cannot Install Package Provider in Intranet Scenario #308

Open MichaelStankiewicz opened 7 years ago

MichaelStankiewicz commented 7 years ago

According to the WMF 5.1 release notes, it states:

Support for PackageManagement on computers with Intranet access only

Solution: In WMF 5.1, you can follow these steps to allow Intranet computers to use PackageManagement:

Download the NuGet provider using another computer that has an Internet connection by using Install-PackageProvider -Name NuGet.

Find the NuGet provider under either $env:ProgramFiles\PackageManagement\ProviderAssemblies\nuget or $env:LOCALAPPDATA\PackageManagement\ProviderAssemblies\nuget.

Copy the binaries to a folder or network share location that the Intranet computer can access, and then install the NuGet provider with Install-PackageProvider -Name NuGet -Source .

However, I follow these instructions to the letter, and I'm not able to get this working for the life of me. Below is the error I'll get when attempting to execute the Install-PackageProvider cmdlet after copying the binaries to a network share (or locally; either way it fails):

Install-PackageProvider : No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags.

Has anyone had success with this, or is this a common issue and simply does not work as advertised?

brywang-msft commented 7 years ago

Do you see any warnings printed before this? Can you confirm the version of NuGetProvider you're trying to install? Since you've referenced WMF 5.1, I assume you're using the PowerShell that came with Windows - is that correct? If so, what version of PowerShell?

There seems to be a manifest issue in different versions of the NuGet provider, but I'm not sure of the correlation yet. I'll schedule this for a 1.1.7.0 hotfix.

@jianyunt Can I point @MichaelStankiewicz to v2.8.5.206-fullclr in the blob store, which seems to work?

gaelcolas commented 7 years ago

@MichaelStankiewicz It works for me, I've created a DSC resource that does this bootstrap for me. Not released to the PSGallery (not up to the task yet), but it's available here: https://github.com/gaelcolas/PackageProviderBootstrap

MichaelStankiewicz commented 7 years ago

@brywang-msft No warnings before the error. The version of the NuGet provider I'm attempting to install is 2.8.5.208. The version of PowerShell I'm using is below for your reference:

Name                           Value
----                           -----
PSVersion                      5.1.14409.1005
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1005
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
MichaelStankiewicz commented 7 years ago

@gaelcolas So looking at your implementation, you aren't using the same cmdlet in question here, so therefore I don't think your statement is accurate when you say it is 'working for you'. Rather, based on what I can see in your code, you are performing a simple file copy operation and not using the cmdlet Install-PackageProvider. I'm not sure how the implementation differs from your logic, but clearly this is not an 'apples to apples' comparison.

gaelcolas commented 7 years ago

True, I meant to say that I managed to get PackageManagement working on offline machines, by using that approach. Apologies for the hasty answer.

brywang-msft commented 7 years ago

Okay, so two things:

  1. The WMF 5.1 release notes are incorrect. There may have been a change that was before my time where the provider name in the manifest was changed from "NuGet" to "NuGetProvider". Hence, the command should be:

    Install-PackageProvider -Name NuGetProvider -Source \\network\location\eh

    @jianyunt @JKeithB What should be the action here?

  2. The latest version of NuGetProvider needs a fix - I forgot to embed the provider manifest when changing the build system. I think the only impacted version is 2.8.5.210. v1.1.6.0 of PackageManagement won't contain this fix, but v1.1.7.0 will.

Action items:

MichaelStankiewicz commented 7 years ago

@brywang-msft I just tested running the Install-PackageProvider command, changed the provider value to 'NuGetProvider', and the command worked. But after running the command, I received a warning. It appears that despite this warning message, the provider was successfully installed because I can register NuGet package sources without issue.

Below is the exact output of my commands:

PS C:\Users\me> get-packageprovider

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

PS C:\Users\me> Install-PackageProvider -Name NuGetProvider -Source \\server\share\PackageManagement\ProviderAssemblies -force

Name                           Version          Source                           Summary
----                           -------          ------                           -------
NuGetProvider                  2.8.5.208        \\server\share...                NuGetProvider
WARNING: Import-PackageProvider failed. Possibly the provider name is different from the package name 'NuGetProvider'.
Try Get-PackageProvider -ListAvailable to identify the associated provider name and run Import-PackageProvider".

PS C:\Users\me> get-packageprovider

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent