Restore from global nuget-repository
I have this packages.config-file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="jQuery" version="3.1.1" targetFramework="net46" />
<package id="NLog" version="4.3.10" targetFramework="net46" />
</packages>
And with this command I can restore nuget-packages, which are listed in above packages.config:
nuget restore packages.config -PackagesDirectory NuGetPackages -NoCache
This works nicely.
All the files for this example can be found here: https://github.com/ezeh2/nuget_restore_examples/tree/master/nuget_with_global_nuget_repository
Restore from local nuget-repository
In my company we have to use a repository, which is located on a network share. And we are not allowed to do package restore from the standard global nuget-repository.
For demonstration-purposes let's assume the local package-repository is in directory NuGetPackagesSource
and this is its content:
-NuGetPackagesSource
|-jquery
|-3.1.1
|-jquery.3.1.1.nupkg
|-jquery.3.1.1.nupkg.sha512
|-jquery.nuspec
|-nlog.4.3.10.nupkg
With this NuGet.Config we make sure that the local package-repository is used instead of the global one:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<disabledPackageSources>
<add key="nuget.org" value="true" />
</disabledPackageSources>
<packageSources>
<add key="my" value="NuGetPackagesSource" />
</packageSources>
</configuration>
Following makes a restore from local directory NuGetPackagesSource
:
nuget restore packages.config -ConfigFile NuGet.config -PackagesDirectory NuGetPackages -NoCache
Unfortunately following errors occur:
WARNING: Unable to find version '3.1.1' of package 'jQuery'. C:\software_download\nuget\NuGetPackagesSource: Package 'jQuery.3.1.1' is not found on source 'C:\software_download\nuget\NuGetPackagesSource'.
Adding package 'NLog.4.3.10' to folder 'C:\software_download\nuget\NuGetPackages' Added package 'NLog.4.3.10' to folder 'C:\software_download\nuget\NuGetPackages'
Errors in packages.config projects Unable to find version '3.1.1' of package 'jQuery'. C:\software_download\nuget\NuGetPackagesSource: Package 'jQuery.3.1.1' is not found on source 'C:\software_download\nuget\NuGetPackagesSource'.
As you can see from the error-message package jquery cannot be restored. But package NLog is successfully restored. I have no explanation
of this behaviour as both packages jquery
and NLog
are in the local package-repository.
All the files for this example can be found here: https://github.com/ezeh2/nuget_restore_examples/tree/master/nuget_with_local_nuget_repository