Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
231 views
in Technique[技术] by (71.8m points)

Nuget Update-Package doesn't recognize installed package --> Update failed

I have installed a NuGet package (which we have developed in the project) in a VS-project. When I run Update-Package on the nuget project i Get:

Update-Package : 'Project name' was not installed in any project. Update failed.
At line:1 char:15
+ Update-Package <<<<  Project name
    + CategoryInfo          : NotSpecified: (:) [Update-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.UpdatePackageCommand

I have checked in the package.config file to make sure the NuGet package is defined, and it is. Any clues?

question from:https://stackoverflow.com/questions/7253763/nuget-update-package-doesnt-recognize-installed-package-update-failed

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I am working on the same project as Tomas and I have tried to figure out when this problem occurs and why. It seems this happens when we have one or more old versions of a package in the packages folder and try to issue the 'update-package' command.

Before issuing the command our packages folder and config looks like this:

Packages folder:

Common.WebApi.1.0.0.109
Common.WebApi.1.0.0.110

Packages config:

<packages>
    <package id="Common.WebApi" version="1.0.0.110" />
    <package id="System.Json" version="4.0.20126.16343" />
    <package id="System.Net.Http" version="2.0.20126.16343" />
</packages>

Now, when issuing 'update-package Common.WebApi' we get the error:
Update-Package : 'OPF.Common.WebApi' was not installed in any project. Update failed.

To fix it I delete the old package 'Common.WebApi.1.0.0.109' from the packages folder and rerun the command which then works.

The obvious question is: Why do I have an old package in my packages folder? This happens to us because we do not committ our own packages to source control. Instead, we use the approach which is described here: http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages

The 'old package problem' occurs in this situation:
1. Developer A updates a package and commits the package.config to source control
2. Developer B gets the latest version from source control and receives the updated package.config
3. Developer B builds the project and the new package is created in his packages folder
4. Nuget does not delete developer B's old package from his packages folder so Developer B now has both the old package and the new package in his packages folder, but only a reference in the package.config to the new version.

To me, it seems that Nuget does not expect there to be more than one version of a package in the packages folder and becomes confused when you to try to update a package that has multiple versions [in the packages folder] even though you only reference a single package from the package.config.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...