I am trying to install NuGet on an offline work machine running Windows Server 2016. Files can be uploaded to this machine via NAS. All online machines have restricted admin rights while the offline machine has full admin rights. I have found installation guides for offline machines, but they all assume that the online machine has admin rights.
How to get PowerShellGet working with no Internet access [Intrepid Integration]
These references recommend that NuGet is installed on an online machine (requires admin rights) then the installed dll is copied to the offline machine. Here's what I've tried so far:
- Tried to download NuGet on the offline machine to see where it downloads the files. It searches: https://onegetcdn.azureedge.net/providers/providers.masterList.feed.swidtag
- Followed the links in the URL and downloaded PackageManagement.NuGetProvider-2.8.5.208.dll
- On a personal computer (with admin rights) I downloaded NuGet the normal way and got the dll PackageManagement.NuGetProvider.dll installed in C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\
- I checked the hash of both dll's and they matched.
- On the offline computer I created a C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208 folder and placed the dll from step 2 into this folder.
- I launched PowerShell as an admin and saw that NuGet 2.8.5.208 was installed but has no DynamicOptions. Any attempt to install nupkg packages failed. Here's what the output of Get-PackageProvider looks like:
PS C:\Windows\system32> Get-PackageProvider -ListAvailable
Name Version DynamicOptions
---- ------- --------------
msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
nuget 2.8.5.208
PowerShellGet 1.0.0.1 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponent
Notice that there are no DynamicOptions for NuGet. It clearly didn't install properly. I repeated this process for version 2.8.5.208 and 2.8.5.205 (both failed). I suspect there's an issue with the metadata of the dll I copied to the offline machine.
How can I get NuGet to install properly on my offline machine without admin rights on the online machines?
Best Answer
Download-Copy-Past solution
Run on your offline or online Windows machine
Install-PackageProvider -Name NuGet
If you receive the following error
then run it with -Scope CurrentUser
Install-PackageProvider -Name NuGet -Scope CurrentUser
We need an URL from received error
Currently this will be https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409
So, go to an online machine and open this URL in a browser.
You'll receive the following XML
Copy the URL of the following form
https://onegetcdn.azureedge.net/providers/nuget-X.X.X.XXX.package.swidtag
Currently it is https://onegetcdn.azureedge.net/providers/nuget-2.8.5.208.package.swidtag
Open this URL in a browser and you'll receive the following XML
You need an URL from the only
href
attribute.This URL allows you to download the current
.dll
file of the current NuGet Provider for PowerShell. Currently it is https://onegetcdn.azureedge.net/providers/Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dllAfter downloading, navigate to this
.dll
file and unlock it (or useUnblock-File
cmdlet)Copy this file to
C:\Program Files\PackageManagement\ProviderAssemblies
on your offline machine.Additional info