2

I would like to check my full solution into a source control repository (GIT). I am well aware of the discussion pertaining to whether or not to check in Nuget packages into source control. For various reasons I have decided I would like to put my Nuget packages in source control.

My question is: What files at minimum should be checked into the repository? There are various files which are obviously part of the build and some which are part of the Nuget setup. Is there some easy way of obtaining only the core (build related) files? I was hoping to do a simple "make clean" and check everything in, however it appears that after doing this, there are still .dll and .pdb files within the Nuget 'packages' directory.

Any guidance on this topic is much appreciated!

Simple Guy
  • 568
  • 5
  • 21

1 Answers1

2

If you do decide to add the packages directory, it is best to check in everything in that directory. Especially the dll files are needed, since they are the built products that are shipped via NuGet, but you can't really tell which files are needed since any NuGet package could contain build logic that can do anything (e.g. use any file included in the package).

It is probably best to use the .gitignore file from GitHub's "VisualStudio" gitignore file and remove the lines concerning the **/packages directory in the section of the file dealing with NuGet packages.

Martin Ullrich
  • 94,744
  • 25
  • 252
  • 217
  • Thanks for your response, Martin. I thought the DLLs were built as required on the local system? I'm not sure how to tell what is the "bare bones" of any given package and hence my question. I am trying to avoid checking in binaries (including DLLs) if possible as they represent several gigabytes of disk space which I don't have available on my remote git server (it's a paid service, so I need to be conscious of the disk space usage). – Simple Guy Jun 14 '17 at 17:44
  • 2
    NuGet packages contain pre-built dlls that are referenced (and copied) during the build process. it is not necessary to check them in, VS can automatically restore packages and `nuget.exe restore` can download them during a scripted build process. but some do check in the packages folder to make sure they can still build if a package is removed from NuGet. – Martin Ullrich Jun 14 '17 at 17:48
  • Thanks, Martin. I didn't realize they were pre-built. I have already decided that I would like all necessary code be within my source control as I do not want to be reliant on a third-party to be able to build my code. It sounds like there is no other way but to clean the directories file-by-file to find the minimal build requirements for my project? – Simple Guy Jun 14 '17 at 17:55
  • 2
    Probably. an alternative would be to create a directory in the project containing all nupkg files and setting the directory as package source instead of nuget.org by creating a `NuGet.Config` file (similar to the NuGet.Config file described in https://stackoverflow.com/a/44463578/784387) – Martin Ullrich Jun 14 '17 at 18:04
  • 1
    (Since the compressed nupkgs usually use less space than the whole directory. and it makes it easier to use Git LFS for the .nupkg files). Note that removing a dependency on the NuGet.org feed doesn't remove the dependency on a 3rd party project if you need a bug fixed in a nuget package.. (esp. if the package is not built from a public open-source project) – Martin Ullrich Jun 14 '17 at 18:06
  • Thanks again for your input, Mark. I have checked your response as the answer. Given what you are saying, I can imagine that the only other alternative if I want to make the repository as small as possible, is to obtain the source for the package if available and put that in source control. – Simple Guy Jun 14 '17 at 20:07