Reputation: 547
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:
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?
Upvotes: 15
Views: 57451
Reputation: 2672
Run on your offline or online Windows machine
Install-PackageProvider -Name NuGet
If you receive the following error
Install-PackageProvider : Administrator rights are required to install packages in 'C:\Program Files\PackageManagement\ProviderAssemblies'. Log on to the computer with an account that has Administrator rights, and then try again, or install in 'C:\Users\\AppData\Local\PackageManagement\ProviderAssemblies' by adding "-Scope CurrentUser" to your command. You can also try running the Windows PowerShell session with elevated rights (Run as Administrator). At line:1 char:1 + Install-PackageProvider -Name NuGet
then run it with -Scope CurrentUser
Install-PackageProvider -Name NuGet -Scope CurrentUser
We need an URL from the received error
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''. WARNING: Unable to download the list of available providers. Check your internet connection. 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.
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
<?xml version="1.0" encoding="utf-8"?>
<SoftwareIdentity xmlns="http://standards.iso.org/iso/19770/-2/2015/schema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:discovery="http://packagemanagement.org/discovery" patch="false" media="(OS:windows)" name="OneGet.Providers" tagVersion="1" uniqueId="OneGet.Providers.1" version="1.15.194.0" versionScheme="multipartnumeric">
<!--
This swidtag is a Discovery Feed that has pointers to the SWIDTAGs for
the providers that the bootstrapper can download.
-->
<Link href="https://onegetcdn.azureedge.net/providers/nuget-2.8.5.208.package.swidtag" type="application/swid-tag+xml" rel="package" discovery:name="nuget" discovery:latest="true" discovery:version="2.8.5.208" media="(OS:windows)" />
<Link href="https://onegetcdn.azureedge.net/providers/psl-1.0.0.210.package.swidtag" type="application/swid-tag+xml" rel="package" discovery:name="psl" discovery:latest="true" discovery:version="1.0.0.210" media="(OS:windows)" />
<Link href="https://onegetcdn.azureedge.net/providers/ChocolateyPrototype-2.8.5.130.package.swidtag" type="application/swid-tag+xml" rel="package" discovery:name="chocolatey" discovery:latest="true" discovery:version="2.8.5.130" media="(OS:windows)" />
<Link href="https://onegetcdn.azureedge.net/providers/nugetv2.feed.swidtag" type="application/swid-tag+xml" rel="feed" discovery:name="nuget" media="(OS:windows)" />
<Link href="https://onegetcdn.azureedge.net/providers/psl.feed.swidtag" type="application/swid-tag+xml" rel="feed" discovery:name="nuget" media="(OS:windows)" />
<Link href="https://onegetcdn.azureedge.net/providers/chocolateyprototype.feed.swidtag" type="application/swid-tag+xml" rel="feed" discovery:name="chocolatey" media="(OS:windows)" />
</SoftwareIdentity>
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
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SoftwareIdentity xmlns="http://standards.iso.org/iso/19770/-2/2015/schema.xsd" xmlns:discovery="http://packagemanagement.org/discovery" xmlns:sha512="http://www.w3.org/2001/04/xmlenc#sha512" name="nuget" versionScheme="multipartnumeric" media="(windows)" tagVersion="1" version="2.8.5.208" uniqueId="nuget.2.8.5.208">
<Meta providerName="nuget" providerVersion="2.8.5.208" summary="NuGet provider for the OneGet meta-package manager" />
<Link href="https://onegetcdn.azureedge.net/providers/Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dll" type="application/octet-stream" rel="installationmedia" discovery:targetFilename="Microsoft.PackageManagement.NuGetProvider.dll" discovery:type="assembly" media="(OS:windows)" />
</SoftwareIdentity>
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.dll
After downloading, navigate to this .dll
file and unlock it (or use Unblock-File
cmdlet)
Copy this file to C:\Program Files\PackageManagement\ProviderAssemblies
on your offline machine.
Upvotes: 16
Reputation: 5
Cant you just install it? https://www.nuget.org/downloads Download the Windows x86 Commandline installer to a thumb drive or shared folder, and install it the old fashioned way, or via a script?
Upvotes: -2