Nuget 包没有 nuget 包管理器?
除了编译的库之外,nuget 包实际上还包含什么?
是否可以在不使用包管理器的情况下下载这些包并在其他地方使用它们?
谢谢!
What does a nuget package actually consist of, apart from the compiled libraries?
Is it possible to download these packages without using the package manager and use them elsewhere?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
您可以从 http://packages.nuget.org/api/v1 下载它们/package// 使用浏览器。
您可以从以下位置获取包名称: http://packages.nuget.org/Packages
示例:
jQuery UI(组合库)包位于: http://packages.nuget.org/packages /jQuery.UI.Combined
下载: http://packages.nuget.org/api/v1 /package/jQuery.UI.Combined/
You can download them from http://packages.nuget.org/api/v1/package/<PACKAGE_YOU_WANT>/ using your browser.
You can get the package name from: http://packages.nuget.org/Packages
Example:
jQuery UI (Combined Library) Package is at: http://packages.nuget.org/packages/jQuery.UI.Combined
To download: http://packages.nuget.org/api/v1/package/jQuery.UI.Combined/
看看这里。基本上,它是一个扩展名为 .nupkg 的文件,只不过是一个 .zip 文件,其中包含上一个链接中解释的结构和一些 xml 元数据。
当然,只需下载
.nupkg
文件即可。Take a look here. Basically it is a file with the
.nupkg
extension which is nothing more than a .zip file containing the structure explained in the previous link and some xml metadata.Sure, simply download the
.nupkg
file.根据 @Gth685 的回答,我制作了一个 Google Chrome 扩展程序,将下载链接添加到 http://nuget.org
https://chrome.google.com/webstore/detail/nutake/ibhhbcaipjilldjkhhblhgdedjgoecap?hl=en
Based on @Gth685's answer, I made a Google Chrome extension that adds download links to package pages on http://nuget.org
https://chrome.google.com/webstore/detail/nutake/ibhhbcaipjilldjkhhblhgdedjgoecap?hl=en
众所周知,您只需在 nuget.org 上创建一个帐户即可。登录后,左侧工具栏上将显示下载链接,您可以直接下载任何 .nupkg 文件。
Just so everyone knows, you can just create an account on nuget.org. Once logged in a download link will appear on the left toolbar that will allow you to directly download any .nupkg file.
补充评论:
下载 *.zip(例如 jquery)后,将结尾从 *.zip 更改为 *.nupkg,然后您可以使用 VS 中的包管理器安装它们。
或许只有我一个人不得不思考这个问题。如果没有,希望有帮助。
Additional comment:
After downloading the *.zip (example jquery) change the ending from *.zip to *.nupkg and then you are able to install them with the Package Manager in VS.
Perhaps it's just me who had to think about it for a while. If not, hope it helps.
抱歉,这应该是一条评论,但我没有足够的代表。
根据这个答案中提到的Chrome扩展程序生成的html,我们可以改进gth685f 的答案指出,要下载不是最新的软件包,URL 是
packages.nuget.org/api/v2/package//
(还要注意递增的 API 版本号)。Sorry, this should be a comment, but I don't have enough rep.
Based on the html generated by the Chrome extension mentioned in this answer, we can improve gth685f's answer by noting that, to download packages that are not the latest, the URL is
packages.nuget.org/api/v2/package/<PACKAGE_YOU_WANT>/<VERSION_NUMBER>
(note the incremented API version number too).需要补充的是,V2 api 与 V1 的格式相同,可以使用浏览器下载包。
http://packages.nuget.org/api/v2/package//
Just to add that the V2 api is the same format as V1 to download a package using your browser.
http://packages.nuget.org/api/v2/package//
引用 NuGet 可能在某些(大多数?)时间有效,但您也可能会遇到版本控制问题。例如,尝试将 Microsoft HTTP 客户端库 NuGet 包 添加到 .NET 4 项目并检查生成的
csproj
文件。首先,您会注意到一些 BCL 程序集已被重写:
现在所有引用项目也必须使用这些重写 (因为您无法引用同一程序集的多个版本)。除此之外,这意味着您会丢失对这些程序集的更新(除非 BCL NuGet 包也已更新)。
您还会注意到您的 csproj 包含以下条目(如果删除它,它将不起作用):
我不了解 MSBuild,但我猜测这可能会影响您的构建环境。
Referencing NuGet may work some (most?) of the time, but you may also run into versioning issues. For example, try adding the Microsoft HTTP Client Libraries NuGet package to a .NET 4 project and examine the resulting
csproj
file.First, you'll notice that some of the BCL assemblies have been overriden:
And now all referencing projects have to use these overrides as well (since you can't reference multiple versions of the same assembly). Among other things, it means you lose updates to those assemblies (unless the BCL NuGet package is updated as well).
You will also notice your csproj contains the following entry (it won't work if you remove it):
I am not knowledgable about MSBuild, but I'm guessing this could affect your build environment.
您还可以使用命令行工具 nuget.exe 下载 nupkg 文件,如下所示:
nuget安装包Id
获取最新版本,或
nuget install packageId -Version 版本
获取具体版本。
You can also use the command line tool nuget.exe to download the nupkg file, like this:
nuget install packageId
to get the latest version, or
nuget install packageId -Version version
to get the specific version.