3

Is it possible to use a Github Repository as a Nuget Source with Paket?

Looking at the documentation https://fsprojects.github.io/Paket/github-dependencies.html it doesn't appear to be the case, and I've tried applying a combination of the Github Repository and Git Repository configuration with no real success.

I've been running myself in circles trying to get an SSH Agent working with our TeamCity configuration with zero luck, in order to just use the plain git dependencies.

Given that this is proving fruitless I'd like to switch to using an auth token with github but can't see any option to combine this with specifying a Package source as well.

Ideally I'm after something like:

github myorganisation/myrepo githubAuthKey Packages: /nuget/
Eric Lease
  • 4,114
  • 1
  • 29
  • 45
Grant Trevor
  • 1,052
  • 9
  • 23

1 Answers1

1

There are two steps to use GitHub as a NuGet repo and you have done one of them. You need to use Paket nuget in the paket.dependencies to actually pull the desired NuGet package from the desired repository/path. The first command which you're issuing is only doing half the work. It is essentially setting your NuGet source. I prefer to use my locally installed git, so instead of Paket's github, I use git, but it is essentially the same...

git https://github.com/<User>/<Priv NuGet repo> [branch|label] Packages: <path to .nupkg files>

nuget <NuGet package ID> <semantic version>

So, if my GitHub repo looks like this...

/.
 -> A.1.0.0.0.nupkg
 -> A.2.0.0.0.nupkg
 -> B.1.0.0.0.nupkg
 -> C.1.0.0.0.nupkg

And I need A, B, and C, all at v1.0.0.0, I would set up my paket.dependencies like so...

git https://github.com/EricLease/MyNuGetRepo master Packages: /
nuget A 1.0.0.0
nuget B 1.0.0.0
nuget C 1.0.0.0

NOTE: If your packages are located under some subfolder in the repo, e.g. /nuget/, then you would change Packages: / to match (Packages: /nuget/)

In paket.references files under I can reference the required package as A, B, or C.

This will result in a paket.lock file that looks like this...

NUGET
  remote: paket-files/github.com/EricLease/MyNuGetRepo
    A (1.0.0.0)
    B (1.0.0.0)
    C (1.0.0.0)
GIT
  remote: https://github.com/EricLease/MyNuGetRepo
     (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
      path: /

Notice that the NUGET remote for those packages is actually set to your local paket-files folder, which gets populated by the GIT remote on packet install update.

Eric Lease
  • 4,114
  • 1
  • 29
  • 45