3

I want to install a NuGet package (so a .nukpg file) that I have stored in a directory. This is easy to do with a batch script, using the NuGet command line, but is there a way to do this using the built in "packages.config" file?

BWG
  • 2,238
  • 1
  • 20
  • 32
  • I just know that the packages.config file specifies the NuGet packages that has been installed into the project. We could re-install it using this file in command line, see : http://stackoverflow.com/questions/6876732/how-do-i-get-nuget-to-install-update-all-the-packages-in-the-packages-config and http://blog.davidebbo.com/2011/03/using-nuget-without-committing-packages.html – Jack Zhai Aug 01 '16 at 04:25
  • @JackZhai You misunderstand... packages.config uses the default nuget repository as a source, I want it to use a local folder as a source for the packages. But its fine, I found a workaround for now. An answer would still be nice though. – BWG Aug 01 '16 at 14:09
  • Actually I didn't find a solution which use the config file directly, how about creating a local NuGet Feeds? https://docs.nuget.org/create/hosting-your-own-nuget-feeds – Jack Zhai Aug 02 '16 at 03:07
  • @JackZhai I've done that already, and I want my feed to be referenced direcly in the packages.config file. Otherwise you have to add the feed to the global nuget settings, or pass in the source of the feed at compile time through command line invocation. Both are non-ideal. – BWG Aug 02 '16 at 13:46
  • I often use VS settings to add it, and install it in command line. Or use the NuGet config file https://docs.nuget.org/consume/nuget-config-file. I didn't find other better workaround. – Jack Zhai Aug 03 '16 at 09:52

1 Answers1

2

Yes, you can reference a local file from your packages.config. You need to update your NuGet.Config file and add something like this to the <packageSources> section:

<packageSources>
  <add key="MyLocalPackages" value="external/packages" />
</packageSources>

value is the path to where your packages can be found.

Then in your packages.config just reference the version that is in your local package directory, like:

<package id="Foobar" version="1.1.5-alpha" targetFramework="net45" />
bratsche
  • 2,666
  • 20
  • 23