简体   繁体   中英

NuGet: Package 'Microsoft.AspNet.WebApi.Client.5.2.3' already exists in folder Install failed. Rolling back

I've formatted my PC and cloned my (previously working) project from the git repo.

I've tried to reinstall packages:

PM> update-package -reinstall

It tried to install many packages, but got an error at Microsoft.AspNet.WebApi.Client.5.2.3 :

Package 'Microsoft.AspNet.WebApi.Client.5.2.3' already exists in folder 'C:\Users\can\Source\Repos\MyProject\MyProject\packages'
Install failed. Rolling back...
Package 'Microsoft.AspNet.WebApi.Client 5.2.3' does not exist in project 'Web'

Then after executing more commands, I get:

update-package : Failed to add reference to 'System.Net.Http'. Please make sure that it is in the Global Assembly Cache.
At line:1 char:1
+ update-package -reinstall
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Update-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand

I've tried deleting the local cache but no avail. I've updated all the packages from the GUI in Visual Studio (Manage NuGet Packages). If I try to build my solution anyway, I get this for two projects (and the solution fails to build):

This project references NuGet package(s) that are missing on this computer.
Use NuGet Package Restore to download them.
For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.
The missing file is ..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets.

What am I doing wring?

If I try to build my solution anyway, I get this for two projects (and the solution fails to build)

That is because the relative path of Microsoft.Bcl.Build.1.0.21 is not correct, need to edit the .csproj file and correct the relative path . Or remove the following code from .csproj file :

  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
  <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />

and then did update-package -reinstall .

Besides, for the reinstall error:

You make sure all packages are restored. Then use the command update-package -reinstall -Project projectname to reinstall packages for each project in the solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM