如何在团队开发中正确使用 NuGet? [英] How to Properly Use NuGet with Team Development?

查看:59
本文介绍了如何在团队开发中正确使用 NuGet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想使用 NuGet 来管理我用于我的团队和我正在从事的特定项目的各种项目.到目前为止,我已将我的 .js 库文件放在我的 Web 解决方案 (ASP.NET MVC 2) 的/Scripts 目录中并引用了这些文件.当然,这是手动的,在升级等过程中管理起来很烦人.

So I would like to use NuGet to manage the various projects I use for a specific project my team and I are working on. Up to this point, I have placed my .js library files in the /Scripts directory of my web solution (ASP.NET MVC 2) and referenced those. Of course, this was manual and was annoying to manage during upgrades, etc.

现在我正在使用 NuGet,我意识到 NuGet 的整个目标是让这变得相当轻松.此外,似乎我不应该将我的包检入我的存储库(也就是我不再需要管理我的外部库).但是,当我从 NuGet 获取 jQuery(例如)时,它会将其特定文件放在我项目的/Scripts 目录中.

Now that I am using NuGet, I realize that the entire goal of NuGet is to make this fairly painless. In addition, it appears that I shouldn't have to check my packages into my repository (AKA I don't need to manage my external libraries anymore). However, when I grab jQuery (for example) from NuGet, it places its specific files in the /Scripts directory of my project.

我感到困惑的地方 - 如果有的话,此时我应该检查源代码管理吗?我还要检查/Scripts 目录吗?

Where I get confused - what, if anything, should I check into source control at this point? Do I still check in the /Scripts directory?

此外,如果其他人正在处理此项目并从源代码管理中检查解决方案,是否会自动下载包(假设解决方案带有有效的packages.config)?

In addition, if someone else is working on this project and checks out the solution from source control, are the packages automatically downloaded (assuming the solution comes with a valid packages.config)?

在我们开始全职使用 NuGet 之前,我只是想澄清几点.

I'm just trying to clarify a couple points before we start using NuGet full-time.

推荐答案

NuGet 与 VCS 有两种方案:签入或不签入,这是个问题.在我看来两者都是有效的,但是当使用 TFS 作为 VCS 时,我肯定会选择 NuGet 包的无签入策略.

There are two scenarios for NuGet vs VCS: to check-in or not to check-in, that's the question. Both are valid in my opinion, but when using TFS as VCS, I'd definitely go for a no-checkin policy for NuGet packages.

话虽如此,即使对 NuGet 包使用无签入策略,我仍会签入这些 NuGet 包对我的项目所做的内容更改.\Scripts 文件夹将被完整签入(不是选择性的,也不是忽略).

That being said, even when using a no-checkin policy for NuGet packages, I'd still checkin the content changes that those NuGet packages have done to my projects. The \Scripts folder would be checked-in in its entirety (not selective, not ignored).

对我来说,包的不签入政策意味着:不签入 \Packages 文件夹 (隐藏它,忽略它),除了 \Packages\repositories.config文件.

The no-checkin policy for packages to me means: not checking in the \Packages folder (cloak it, ignore it), except for the \Packages\repositories.config file.

因此,您实际上并未提交任何 NuGet 包,并且当使用 NuGetPowerTools 中的 Enable-PackageRestore 时(即将在 NuGet v1.6 中内置),任何检查代码和构建的机器将在预构建步骤中获取所有必需的 NuGet 依赖项.只要在您的解决方案中启用 Enable-PackageRestore 并指向正确的 NuGet 存储库(本地、内部、外部),本地开发机器和构建服务器都是如此.

As such, you are effectively not committing any NuGet packages, and when using Enable-PackageRestore from the NuGetPowerTools (this will be built-in in NuGet v1.6 just around the corner), any machine that checks out the code and builds, will fetch all required NuGet dependencies in a pre-build step. This is true for both local development machines as for build servers, as long as Enable-PackageRestore is enabled in your solution and points to the correct NuGet repositories (local, internal, external).

如果你考虑一下,当安装一个只添加对某些二进制文件的引用的 NuGet 包时,你已经在无签入场景中做同样的事情:你不会提交 \Packages 文件夹的子文件夹,但您仍然需要提交项目更改(添加的引用).

If you think about it, when installing a NuGet package that only adds references to some binaries, you'd already be doing the samething in a no-checkin scenario: you would not commit the \Packages folder's subfolders, but still, you'd commit the project changes (the added reference).

我想说,保持一致(对于任何类型的包),无论它只包含二进制文件、仅包含内容还是混合.不要提交包自己,请务必将更改提交到您的源.(如果只是为了避免查找内容更改的麻烦)

I'd say, be consistent (for any type of package), whether it contains binaries only, content only, or a mix. Do not commit the packages themselves, do commit the changes to your sources. (if only to avoid the hassle of looking up what changed content-wise)

这篇关于如何在团队开发中正确使用 NuGet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆