c# - 直接添加引用和通过Nuget添加包有什么区别

标签 c# powershell nuget

我想在我的C#项目中引用Powershll5.0中的system.management.automation.dll,手动添加引用和通过Nuget添加有什么区别包裹?
我如何保证运行我的应用程序的机器在引用路径中有这个程序集?即使我在我的应用程序安装程序中包含这个 dll,这个 dll 不在引用路径中,机器可以自动定位这个 dll 吗?

最佳答案

What is the difference of adding reference directly and adding package by Nuget

NuGet本质上和手动添加引用没有什么区别,最终都是为项目添加引用。它是一个自动为我们添加程序集并进行管理的工具,有效的提高了我们开发项目的效率。

更多的细节,你可以查看关于nuget的文档:

Put simply, a NuGet package is a single ZIP file with the .nupkg extension that contains compiled code (DLLs), other files related to that code, and a descriptive manifest that includes information like the package's version number. Developers with a code to share create packages and publish them to a public or private host. Package consumers obtain those packages from suitable hosts, add them to their projects, and then call a package's functionality in their project code. NuGet itself then handles all of the intermediate details.

Because NuGet supports private hosts alongside the public nuget.org host, you can use NuGet packages to share code that's exclusive to an organization or a workgroup. You can also use NuGet packages as a convenient way to factor your own code for use in nothing but your own projects. In short, a NuGet package is a shareable unit of code, but does not require nor imply any particular means of sharing.

Is it just that .nupkg can contain a whole bunch of other things aside from a .dll (e.g. documentation)?

是的,NuGet 包可以在包中包含指定文件。

Why would I use one or the other?

Nuget 提供了几个额外的好处:

  • 它通过添加对必要程序集的引用、创建和添加项目文件(例如配置)等来自动配置您的项目。
  • 它提供软件包更新。
  • 它可以非常方便地完成所有这些工作。
  • 我相信一旦您使用它,您就会发现它有很多好处。

希望对您有所帮助。

关于c# - 直接添加引用和通过Nuget添加包有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55700750/

相关文章:

c# - 如何获取 RichTextBox 的行数

powershell - 如何导出 Azure 订阅上的 "administrators"列表?

powershell - 立即查找定义为文字的哈希表中的值

c# - 将卢比符号添加到我的 gridview 列

c# - 在 WPF 中绑定(bind)两个依赖属性

c# - ListBox Groupstyle 显示 : How to design a group name?

email - Powershell:如何为电子邮件格式化 Get-Childitem?

git - 如何修复丢失的 NuGet 包错误?

c# - .NET — 管理不同版本的 NuGet 包的常见依赖关系

asp.net-mvc - NuGet将恶意行添加到web.config MVC4