为什么我们需要像 Nuget 这样的包管理器? [英] Why we need a package manager like Nuget?

查看:45
本文介绍了为什么我们需要像 Nuget 这样的包管理器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道像 NuGet 这样的包管理器可以在我们想要使用第三方组件时帮助我们.

I know Package Manager like NuGet help us when we want to use third party components.

来自 Nuget Codeplex 页面:

From Nuget Codeplex Page:

NuGet 是一个免费的、开源的、专注于开发者的包管理.NET 平台的系统旨在简化流程将第三方库合并到 .NET 应用程序中发展.

NuGet is a free, open source developer focused package management system for the .NET platform intent on simplifying the process of incorporating third party libraries into a .NET application during development.

有大量有用的 3rd 方开源库适用于 .NET 平台,但适用于不熟悉 OSS 的人生态系统,将这些库拉入项目可能会很痛苦.

There are a large number of useful 3rd party open source libraries out there for the .NET platform, but for those not familiar with the OSS ecosystem, it can be a pain to pull these libraries into a project.

我们以 ELMAH 为例.这是一个很好的错误记录实用程序它不依赖于其他库,但仍然是一个挑战集成到一个项目中.这些是它需要的步骤:

Let’s take ELMAH as an example. It’s a fine error logging utility which has no dependencies on other libraries, but is still a challenge to integrate into a project. These are the steps it takes:

Find ELMAH
Download the correct zip package.
"Unblock" the package.
Verify its hash against the one provided by the hosting environment.
Unzip the package contents into a specific location in the solution.
Add an assembly reference to the assembly.
Update web.config with the correct settings which a developer needs to search for. 

这是一个没有依赖关系的库.想象一下这样做对于 NHibernate.Linq,它有多个依赖项,每个依赖项都需要类似的步骤.我们可以做得更好!

And this is for a library that has no dependencies. Imagine doing this for NHibernate.Linq which has multiple dependencies each needing similar steps. We can do much better!

NuGet 自动执行包的所有这些常见和乏味的任务以及它的依赖项.它消除了几乎所有的挑战将第三方开源库纳入项目的源树

NuGet automates all these common and tedious tasks for a package as well as its dependencies. It removes nearly all of the challenges of incorporating a third party open source library into a project’s source tree

这些步骤是我们想要设置项目时执行的简单任务.它仅用于自动添加 3rd 方组件并规定配置文件中出现错误的可能性?或者它有更多的责任!?

these steps are simple tasks that we do when we want to setup a project. its only for automation of adding 3rd party components and decrees chance of Error in configuration files? or it has much more responsibilities !?

推荐答案

它的价值隐藏在公开中:包管理器(例如 NuGet)可帮助您使用自动化处理软件依赖项.许多人假设它仅适用于开源或第三方组件,但您同样可以将其用于自己的内部包.

It's value is hidden in the open: a package manager such as NuGet helps you dealing with software dependencies using automation. Many make the assumption that it's only meant for open source or third party components, but you could equally as well use it for your own internal packages.

NuGet 的优点在于(仅举几个好处):

The great thing about NuGet is (to name a few benefits):

  • NuGet 鼓励重用组件,因为您隐式依赖实际的发布"(即使是预发布),而不是分支源
  • 您可以摆脱使 VCS 存储库膨胀的二进制文件(包还原功能)
  • 它迫使包创建者考虑使用包的方式,并让他们在包安装期间处理组件的配置(谁比包创建者更了解如何配置包?).以 ELMAH 为例.
  • 在包存储库上有效地自动化包创建和发布是持续交付的一种形式(对于软件组件).OctopusDeploy 甚至更进一步,可以打包整个网站以备部署.
  • NuGet 鼓励并有时强制您遵循一些 ALM 最佳实践.例如.一个包有一个版本,所以你必须考虑你的版本控制策略(例如 SemVer.org)
  • NuGet 与 SymbolSource.org 集成(它也有一个社区版来设置你自己的):这使人们可以轻松调试已发布的包,而无需一直发送此信息
  • 拥有一个或多个包存储库使组织可以轻松维护依赖关系矩阵,甚至可以构建多个项目正在使用的 OSS 许可证清单
  • NuGet 会通知您可用的软件包更新
  • 创建包让人思考组件架构(所有依赖也应该打包)
  • 包的依赖项会自动解决(因此您不会忘记任何)
  • NuGet 足够智能,可以在需要时添加程序集绑定重定向

以上列表并非详尽无遗,但我希望我在此答案中涵盖了主要优点.我确定还有更多.

The above list is non-exhaustive, but I hope I covered the key benefits in this answer. I'm sure there are more.

干杯,泽维尔

这篇关于为什么我们需要像 Nuget 这样的包管理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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