Reputation: 42155
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>
Upvotes: 4
Views: 6273
Reputation: 42383
Is your packages\repositories.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.
Upvotes: 2