使用 NuGet 进行内部和外部访问TFS 中的外部依赖项

发布于 2024-12-08 17:35:40 字数 441 浏览 0 评论 0原文

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

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

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

另外,请注意,我打算使用 NuGet,而不将包提交到 TFS。我计划使用本文中的方法大纲:

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

I'm currently looking at NuGet to solve my dependency problems in TFS and what I wanted to do is to host my own NuGet server that would take care of internal dependencies. I also want to use NuGet to handle my 3rd party dependencies as well. I'm trying to set up automated builds for our company and this is one roadblock I'm trying to overcome with NuGet.

So my question is how do I handle this scenario in which I have to retrieve my dependencies from different servers?

Is there a better way to handle internal dependencies? How is everyone else doing this?

Also just as a note I intend on using NuGet without committing packages to TFS. I planned on using the method outline in this article:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

此刻的回忆 2024-12-15 17:35:40

很高兴您正在研究 TFS 上 NuGet 包的无提交场景。您可以查看 我的博客文章关于这个主题,我解释了这个概念。

编辑(2012/06/13):NuGetPowerTools 被 NuGet 的内置包恢复功能取代。但是,更改 nuget.targets 中的 PackageSources 元素的相同概念仍然适用。

您绝对应该看看 David Fowler 的 NuGetPowerTools
安装此软件包后,您可以Enable-PackageRestore(软件包管理器控制台中新安装的命令),这将添加...

启用包还原会将 MSBuild 目标添加到您的项目文件中。这些 MSBuild 目标将在预构建步骤中触发 nuget.exe 并获取项目所需的任何包。
无需在源代码管理中签入 NuGet 包,您所需要的只是packages.config 和这些 msbuild 任务。

要配置多个不同的包源,您需要设置这些 MSBuild 任务要使用的一些设置。其中之一是 PackageSources。您可以通过编辑 NuGet.targets 文件来设置它,启用包还原后,您将在 .nuget 文件夹中找到该文件。

对于这些包源,您可以设置不同的内部 NuGet 库,或者简单地设置要使用的不同网络共享。这是一个要求和偏好的问题,所以你可以选择。您需要做的就是告诉您的 msbuild 目标使用这些包源。您定义它们的顺序也将是查找包的顺序。

祝你好运!
泽维尔

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

若言繁花未落 2024-12-15 17:35:40

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

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

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

  2. 注释掉该行:

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

  3. 配置您需要的包源。

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

Little update on accepted answer and question:

When using TFS as a buildmachine without visual studio installed on it, you can do the following so the buildmachine automatically uses your custom packageSources (more than 1 in the same solution) without any further configuration of packagesources in your solution.

  1. Create a machine default config by placing a NuGet.Config in the root ( C:\NuGet.Config ) by using sample from: http://docs.nuget.org/docs/reference/nuget-config-file

  2. Comment out the line with: <add key="repositorypath" value="$\External\Packages" />

    Otherwise your packages gets expanded in C:\$\External\packages\'. When commented out, the config gets chained and the right directory will be used.

  3. Config your needed packagesource(s).

For more Info about other options (e.g. user specifc) see: http://docs.nuget.org/docs/reference/nuget-config-file (bottom of the page).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文