[英]NuGet Package Manager Console: “update-package -project …” doesn't update all installed packages
I have a packages config in ProjectX as follows:我在 ProjectX 中有一个包配置,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="2.5.2" />
<package id="Castle.Windsor" version="2.5.3" />
<package id="CommonServiceLocator" version="1.0" />
<package id="MyCompany.Enum" version="1.1.0.11" />
<package id="MyCompany.Common" version="1.1.0.9" />
<package id="MyCompany.Castle.Installers" version="1.1.0.13" />
</packages>
When I issue the following command in the Package Manage Console:当我在 Package 管理控制台中发出以下命令时:
update-package -project ProjectX
I see the following output:我看到以下 output:
No updates available for 'MyCompany.Castle.Installers'.
No updates available for 'CommonServiceLocator'.
No updates available for 'Castle.Windsor'.
No updates available for 'Castle.Core'.
I happen to know for a fact that there is a newer MyCompany.Enum
, so why isn't it being listed in the output?我碰巧知道有一个更新的
MyCompany.Enum
,那么为什么它没有列在 output 中? I know that NuGet tries to use the lowest suitable version when you install, but in this case I want update-package
to update it to the latest version.我知道 NuGet 在安装时会尝试使用最低的合适版本,但在这种情况下,我希望
update-package
将其更新到最新版本。
I tried forcing it to update MyCompany.Enum
with the following command:我尝试使用以下命令强制它更新
MyCompany.Enum
:
update-package -project MyCompany.Services.MyService MyCompany.Enum
And this time got an error message:而这一次得到了一个错误信息:
Update-Package : Unable to find package 'MyCompany.Enum' in 'MyCompany.Services.MyService'.
At line:1 char:15
+ update-package <<<< -project MyCompany.Services.ProjectX MyCompany.enum
+ CategoryInfo : NotSpecified: (:) [Update-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.UpdatePackageCommand
This is very strange, because MyCompany.Enum
is listed both in the packages.config
and is referenced by ProjectX in the Solution Explorer.这很奇怪,因为
MyCompany.Enum
既列在packages.config
中,又被解决方案资源管理器中的 ProjectX 引用。
What could be the explanation for this?对此有何解释? If it's a nuget bug, fine, but I expect I'm misunderstanding something about how it works.
如果它是 nuget 错误,很好,但我希望我误解了它的工作原理。 I've heard of similar weird goings-on with the
repositories.config
, but haven't been able to link any of those issues with what I'm seeing here.我听说过
repositories.config
发生了类似的奇怪事情,但无法将这些问题与我在这里看到的问题联系起来。
Many thanks in advance.提前谢谢了。
UPDATE更新
If I manually install the MyCompany.Enum
package to ProjectX, using this command:如果我手动将
MyCompany.Enum
package 安装到 ProjectX,请使用以下命令:
install-package -project ProjectX MyCompany.Enum
Then I get this output:然后我得到这个 output:
'MyCompany.Enum 1.5.0.1' already installed.
Successfully added 'MyCompany.Enum 1.5.0.1' to MyCompany.Services.ProjectX.
But sadly, now I have two instances of MyCompany.Enum
in my packages.config
file:但遗憾的是,现在我的
packages.config
文件中有两个MyCompany.Enum
实例:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="2.5.2" />
<package id="Castle.Windsor" version="2.5.3" />
<package id="CommonServiceLocator" version="1.0" />
<package id="MyCompany.Enum" version="1.1.0.11" />
<package id="MyCompany.Common" version="1.1.0.9" />
<package id="MyCompany.Castle.Installers" version="1.1.0.13" />
<package id="MyCompany.Enum" version="1.5.0.1" />
</packages>
Is your packages\repositories.config
present and correct?您的
packages\repositories.config
是否存在且正确?
Because most people don't check the packages folder in, the file gets lost.因为大多数人不检查包文件夹,所以文件会丢失。 Some of the NuGet commands look in there first, and fail.
一些 NuGet 命令首先查看那里,然后失败。 Some actions (such as installing a package in the project) will cause it to re-generate.
某些操作(例如在项目中安装 package)会导致它重新生成。
I had a very similar issue with updates not working, but once I added a new project, they then started working correctly.我有一个非常相似的问题,更新不起作用,但是一旦我添加了一个新项目,它们就会开始正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.