Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nexus to serve up Chocolately packages

Tags:

chocolatey

Not coming from a NuGet background, I don't understand how to setup Nexus to serve up Chocolatey packages.

like image 302
Dennis Hoer Avatar asked Aug 24 '17 17:08

Dennis Hoer


People also ask

Where are chocolatey packages?

The package contents are installed into c:\programdata\chocolatey\lib<package id>. Chocolatey takes a registry snapshot to compare later. If there are automation scripts (usually PowerShell), they run at this time.


1 Answers

Here is how you do it:

  1. Create a NuGet proxy repository that points to https://chocolatey.org/api/v2/. This will allow you to cache packages from chocolatey.org which can come in handy if it goes down during a deployment.
  2. Create a NuGet hosted repository. This is where you will publish your private packages.
  3. Create a group repository that contains the above repositories. This what you will set --source flag to when installing a package.

The NuGet tab under hosted repo created above will have the Package Source and Personal API Key.

So if hosted repo has:

Package Source = "https://example.com/nexus/service/local/nuget/choco-releases/"
Personal API Key = "d8471cc1-d350-3e45-a0c2-95d0b938e1d9"

Then the call to package and publish your private mypackage package would look like this:

choco pack
choco push --source "'https://example.com/nexus/service/local/nuget/choco-releases/'" -k="'d8471cc1-d350-3e45-a0c2-95d0b938e1d9'"

To install packages from both private and public sources, use the group repository as the source. The NuGet tab under group repo created above will have the Package Source to use.

So if the group repo has:

Package Source = "https://example.com/nexus/service/local/nuget/choco-all/"

Then the call to install both your private and publicly available packages would look something like this:

choco install jdk8 mypackage --source "'https://example.com/nexus/service/local/nuget/choco-all/'" 

When the jdk8 package is not in the private repo; Nexus will pull it from chocolatey.org, cache it in the proxy repo, then send it on to where choco install is called.

like image 157
Dennis Hoer Avatar answered Oct 20 '22 14:10

Dennis Hoer