15

我目前正在寻找 NuGet 来解决我在 TFS 中的依赖问题,我想做的是托管我自己的 NuGet 服务器来处理内部依赖关系。我还想使用 NuGet 来处理我的第 3 方依赖项。我正在尝试为我们公司设置自动化构建,这是我试图通过 NuGet 克服的一个障碍。

所以我的问题是如何处理这种我必须从不同服务器检索我的依赖项的场景?

有没有更好的方法来处理内部依赖?其他人是怎么做到的?

另外,我打算在不将包提交到 TFS 的情况下使用 NuGet。我计划使用本文中的方法大纲:

http://blog.davidebbo.com/2011/08/easy-way-to-set-up-nuget-to-restore.html

4

2 回答 2

11

Glad you're looking into the no commit scenario for NuGet packages on TFS. You can take a look at my blog post on this topic where I explain the concept.

EDIT (2012/06/13): NuGetPowerTools is replaced by NuGet's built-in package restore functionality. However, same concept of changing the PackageSources element in nuget.targets still applies.

You definitely should take a look at David Fowler's NuGetPowerTools. After installing this package, you can Enable-PackageRestore (newly installed command in Package Manager Console), which will add... Enabling package restore will add MSBuild targets to your project files. These MSBuild targets will trigger nuget.exe in a pre-build step and fetch any packages required by your project. No need to check-in NuGet packages in source control, all you need is the packages.config and these msbuild tasks.

To configure multiple, different package sources, you need to set some settings to be used by these MSBuild tasks. One of them is PackageSources. You can set it by editing the NuGet.targets file, which you will find in the .nuget folder once you enabled package restore.

Regarding those package sources, you could set up different internal NuGet galleries, or simply set up different network shares to be used. This is a matter of requirements and preference, so you can choose. All you need to do, is to tell your msbuild targets to use these packagesources. The order in which you define them, will be the order of lookup of packages as well.

Good luck! Xavier

于 2011-10-07T18:07:11.453 回答
1

接受的答案和问题的更新很少:

将 TFS 用作未安装 Visual Studio 的构建机器时,您可以执行以下操作,以便构建机器自动使用您的自定义 packageSources(同一解决方案中超过 1 个),而无需在您的解决方案中进一步配置 packagesources。

  1. 通过使用来自http://docs.nuget.org/docs/reference/nuget-config-file的示例将 NuGet.Config 放置在根 ( C:\NuGet.Config ) 中来创建机器默认配置

  2. 注释掉这一行:<add key="repositorypath" value="$\External\Packages" />

    否则你的包会在 C:\$\External\packages\' 中展开。注释掉后,配置会被链接起来,并且将使用正确的目录。

  3. 配置您需要的包源。

有关其他选项(例如用户特定)的更多信息,请参阅:http ://docs.nuget.org/docs/reference/nuget-config-file (页面底部)。

于 2013-08-15T12:46:21.467 回答