English 中文(简体)
NuGet Package Manager Console: "update-package -project ..." doesn t update all installed packages
原标题:

I have a packages config in ProjectX as follows:

<?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:

update-package -project ProjectX

I see the following 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? 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.

I tried forcing it to update MyCompany.Enum with the following command:

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.

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. 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.

Many thanks in advance.

UPDATE
If I manually install the MyCompany.Enum package to ProjectX, using this command:

install-package -project ProjectX MyCompany.Enum

Then I get this 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:

<?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 epositories.config present and correct?

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. Some actions (such as installing a package in the project) will cause it to re-generate.

I had a very similar issue with updates not working, but once I added a new project, they then started working correctly.





相关问题
Best practices for Subversion and Visual Studio projects

I ve recently started working on various C# projects in Visual Studio as part of a plan for a large scale system that will be used to replace our current system that s built from a cobbling-together ...

Enable PHP highlights in VS 2010?

I ve heard that Visual Studio 2010 Beta 2 has support for PHP. When I load a PHP file though, it has nothing highlighted and is nothing more than a glorified text editor. Is there a way to enable it?...

Do I want Publish or Release Build in VB.net?

I wrote a little (like 40 lines little) Winforms application with VB.net in Visual Studio 2010. Now I ve released the code as a Google Code project. It s easy for a developer to get the source but I d ...

Unit Testing .NET 3.5 projects using MStest in VS2010

There s a bug/feature in Visual Studio 2010 where you can t create a unit test project with the 2.0 CLR. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483891&wa=...

热门标签