Recursively include Nuget DLLs via Gitignore

纵饮孤独 提交于 2019-12-03 17:15:41

问题


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???


回答1:


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

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




回答2:


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.



来源:https://stackoverflow.com/questions/7374591/recursively-include-nuget-dlls-via-gitignore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!