的NuGet的恢复套餐坚持特定的软件包版本 [英] NuGet's Restore Package insists on specific package versions

查看:216
本文介绍了的NuGet的恢复套餐坚持特定的软件包版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经与以下packages.config项目:

I've a project with the following packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Framework.Infrastructure.Core" version="1.4.0.6" />
  <package id="Framework.Infrastructure.Extensions" version="1.4.0.6" />
</packages>

凡框架。*包都坐在我们的本地仓库。

Where the Framework.* packages are sitting in our local repository.

我已经启用包还原,并增加了我们的内部回购该人士透露。然而,当我试着从packages.config恢复包(基本上不的NuGet安装packages.config -sources .... ),我收到以下错误:

I've enabled Package Restore and added our internal repo to the sources. However, when I try restoring the packages from packages.config (which essentially does nuget install packages.config -sources....), I get the following errors:

error : Unable to find version '1.4.0.6' of package 'Framework.Infrastructure.Extensions'
error : Unable to find version '1.4.0.6' of package 'Framework.Infrastructure.Core'.

该库不再包含在 1.4.0.6 封装的版本(这是相关几个月前),而是它的新版本(例如, 1.5.1.6 )。

The repository no longer contains the 1.4.0.6 version of the package (which was relevant a couple of months ago), but rather the new version of it (e.g., 1.5.1.6).

为什么没有的NuGet找到包的新版本?有一些语法,我可以在packages.config指定确保的最新版本将被下载?

Why doesn't NuGet find the new versions of the packages? Is there some syntax I can specify in packages.config to ensure that the latest versions will be downloaded?

总之,有什么短编写自定义脚本来更新,我可以做的包?

In short, is there anything short of writing a custom script to update the packages that I can do?

感谢你。

推荐答案

我觉得有些人误解了什么包还原的意思做。此功能被添加到的NuGet仅用于不需要包进行检查入版本控制的目的。很多人都抱怨commiting二进制文件爆炸的资料库的大小,并使用类似的git,在整个回购被下载到本地,并包括每一个版本的软件包foo的DVCS时,更是雪上加霜。

I think some people are misunderstanding what Package Restore is meant to do. This feature was added to NuGet solely for the purpose of not requiring packages to be checked into version control. A lot of people were complaining that commiting binaries were exploding the size of their repositories, and is even worse when using a DVCS like git, where the entire repo is downloaded locally and includes every version of package Foo.

那么究竟是什么包还原呢?基本上,它看起来在每个项目中的packages.config并简单地拉下列出的包的特定版本。这就像删除你的包文件夹,​​然后做的git的复位 - 硬来把他们带回(假设该文件夹被检查的)。

So what exactly does Package Restore do? Basically it looks in packages.config of each project and simply pulls down the specific version of the package listed. It's like deleting your packages folder, then doing git reset --hard to bring them back (assuming the folder was checked in).

为什么这很重要?为什么不升级到最新的包版本?如果您认为最常见的用例包的恢复,这是做自动化的构建,应该给你一个线索。构建服务器只应构建进行了测试,并承诺由开发项目。如果让构建服务器决定何时更新包,那么你有没有经过测试任何人的一个项目。作为开发人员,你应该是一个决定何时做了升级。

Why is this important? Why not upgrade to the latest package version? If you consider the most common use case of Package Restore, which is to do automated builds, that should give you a clue. The build server should only be building the project that was tested and committed by a developer. If you let the build server decide when to update a package, then you have a project that has not been tested by anyone. As a developer, you should be the one to decide when to do the upgrade.

记住,在安装或更新一个包不是简单地拉下一个.nupkg文件并添加引用。很多包有副作用如更新你的.config文件,添加code等。当你安装一个软件包,所有这些副作用发生在你的本地副本。现在,您可以提交您的code和排除的程序包文件。

Remember, installing or updating a package is not simply pulling down a .nupkg file and adding references. A lot of packages have side-effects like updating your .config files, adding code, etc. When you install a package, all of those side-effects happen on your local copy. You can now commit your code and exclude the package files.

当另一个开发者或构建服务器签出code,他将有相同的副作用code你不得不减去包文件。包还原只需拉这些文件下来的的NuGet库,现在我们拥有一切需要工作在这个项目上。

When another developer or the build server checks out the code, he'll have the exact same side-effect code you had minus the package files. Package Restore simply pulls these files down from the NuGet repository and now we have everything needed to work on this project.

本的NuGet团队已经承诺将维持所有版本的软件包,让你随时都可以拉下正确的版本。然而,正如我们看到在几个月前,当的NuGet服务器停机,这pretty的多残废包还原,很多人都无法建立。

The NuGet team has promised to maintain all versions of packages so that you will always be able to pull down the correct version. However, as we saw a few months ago, when the NuGet server went down, it pretty much crippled Package Restore and a lot of people were unable to build.

我建议你设置自己的NuGet库(简单文件共享会做),并保持所有你使用有包装的副本。这样,你不依赖外部服务器的基础上。而作为的NuGet队呢,你应该把所有版本的软件包。这样,如果你要回去和建设项目的旧版本,你就一定要有正确的软件包版本。

I recommend that you setup your own NuGet repository (a simple file share would do) and keep copies of all packages you use there. This way you are not dependent on an external server for your builds. And as the NuGet team does, you should keep ALL versions of a package. This way if you have to go back and build an older version of your project, you will be sure to have the correct package versions available.

我希望这解释了功能的工作原理和为什么它会奏效的方式。

I hope this explains how the feature works and why it works that way.

这篇关于的NuGet的恢复套餐坚持特定的软件包版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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