Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recursively include Nuget DLLs via Gitignore

I am using GIT with a new ASP.NET MVC project. I have a line in my gitignore file to ignore dlls

*.dll

I would like to add something along the lines of the following to include (i.e. do not ignore) DLLs in my NUGET packages folder

  !/packages/*.dll

The problem I'm encountering is that not all nuget packages are created equally and, depending on the package in question, DLLs may be nested an arbitrary number of levels in the path hierarchy. It seems that I simply need a recursive solution along the lines of:

!/packages/**/*.dll

!/packages/**/*

I have not yet found a solution that will work via mysysgit (or any windows distribution of git).

Does anyone know of a way to make this work???

like image 420
Jason Irwin Avatar asked Sep 10 '11 20:09

Jason Irwin


2 Answers

Leave your top level gitignore alone by keeping *.dll in it.

Create another .gitignore file in the packages directory and put !*.dll in it.

like image 187
vcsjones Avatar answered Oct 06 '22 07:10

vcsjones


Another option to consider is NOT including your NuGet dlls in your repository and instead only download them the first time you build your project. This is what we do with all of our NuGet dependencies.

UPDATE

Nuget handles this now without having to manually create your own build events. See the details on this page: http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages


Original Answer:

We put the NuGet.exe application in a tools folder under our solution, and then add the following to our project pre-build event.

"$(SolutionDir)Tools\NuGet.exe" install "$(ProjectDir)packages.config" -o "$(SolutionDir)Packages"

The first time we build the app it will download all of the dependencies, but with subsequent builds, NuGet is smart enough to see that they already exist at the correct version and skips them.

like image 43
Timothy Strimple Avatar answered Oct 06 '22 07:10

Timothy Strimple