使用较新版本的 NuGet,不再需要对 packages
文件夹进行版本控制,将其添加到 .gitignore
文件中非常简单。
但是,某些 NuGet 包还会将文件添加到 Contents
文件夹,问题是如何处理?我认为那些文件也应该被 git 忽略,但是维护可能复杂的内容排除规则是否可行?
最佳答案
当您阅读“Enabling Using NuGet Without Checking In Packages Folder”的理由时,它是关于:
This new feature will make it so that if the packages folder (or any package folder within the packages folder) is missing, the packages folder (or missing package folder) will automatically be restored when compiling the application. This ensures that the application will compile even though the packages folder was missing at the time.
所以基本上可以重新生成的内容没有版本控制。
一般的想法是,如果它不能轻易地重新生成或获取,则应该对其进行版本控制。
而且您放入 Content
的内容似乎不属于该类别,如文章“Creating a NuGet Package in 7 easy steps - Plus using NuGet to integrate ASP.NET MVC 3 into existing Web Forms applications”中的示例所示;
Step 2 - Add stuff to your
Content
FolderSince I want my NuGet package to add stuff to folders in my target Web Application, I put whatever I want in a folder called Content. Anything in that will show up in the root of my target project. This can be CSS, JS, CS or VB files, whatever. These files will all get dropped onto the project your package is applied to.
所以版本控制说 Content
可能是可取的。
关于version-control - NuGet 和版本控制 - 如何处理目录文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9102344/