Nuget Update-Package -reinstall失败并出现InvalidOperationException

时间:2017-12-01 06:47:05

标签: c# visual-studio-2010 nuget nuget-package-restore

我有一个包含3个项目的Visual Studio 2010解决方案。它们中的每一个都有一个packages.config文件,如下所示:

项目1:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="log4net" version="2.0.8" targetFramework="net40" />
  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="net40" />
  <package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net40" />
  <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net40" />
</packages>

项目2:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="log4net" version="2.0.8" targetFramework="net40-Client" requireReinstallation="True" />
  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="net40-Client" />
  <package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net40-Client" />
  <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net40-Client" />
</packages>

项目3:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="log4net" version="2.0.8" targetFramework="net40" />
  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="net40" />
  <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
  <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net40" />
</packages>

我想干净地安装这些依赖项。我正在使用Nuget Package Manager版本2.8.60318.667和Visual Studio 2010 Ultimate版。

我在Nuget Package Manager控制台中运行了以下命令:

Update-Package -reinstall

我收到以下消息:

PM> Update-Package -reinstall
Reinstalling 'log4net 2.0.8' in project 'Project 2'.
Removing 'log4net 2.0.8' from Project 2.
Successfully removed 'log4net 2.0.8' from Project 2.
Reinstalling 'Microsoft.Bcl 1.1.10' in project 'Project 2'.
Removing 'Microsoft.Bcl 1.1.10' from Project 2.
Successfully removed 'Microsoft.Bcl 1.1.10' from Project 2.
Reinstalling 'Microsoft.Bcl.Build 1.0.21' in project 'Project 2'.
Removing 'Microsoft.Bcl.Build 1.0.21' from Project 2.
Successfully removed 'Microsoft.Bcl.Build 1.0.21' from Project 2.
Reinstalling 'Microsoft.Net.Http 2.2.29' in project 'Project 2'.
Removing 'Microsoft.Net.Http 2.2.29' from Project 2.
Successfully removed 'Microsoft.Net.Http 2.2.29' from Project 2.
Reinstalling 'log4net 2.0.8' in project 'Project 1'.
Removing 'log4net 2.0.8' from Project 1.
Successfully removed 'log4net 2.0.8' from Project 1.
Reinstalling 'Microsoft.Bcl 1.1.10' in project 'Project 1'.
Removing 'Microsoft.Bcl 1.1.10' from Project 1.
Successfully removed 'Microsoft.Bcl 1.1.10' from Project 1.
Reinstalling 'Microsoft.Bcl.Build 1.0.21' in project 'Project 1'.
Removing 'Microsoft.Bcl.Build 1.0.21' from Project 1.
Successfully removed 'Microsoft.Bcl.Build 1.0.21' from Project 1.
Uninstalling 'Microsoft.Bcl.Build 1.0.21'.
Access to the path 'C:\path-to-project\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.Tasks.dll' is denied.
Access to the path 'Microsoft.Bcl.Build.Tasks.dll' is denied.
Successfully uninstalled 'Microsoft.Bcl.Build 1.0.21'.
Reinstalling 'Microsoft.Net.Http 2.2.29' in project 'Project 1'.
Removing 'Microsoft.Net.Http 2.2.29' from Project 1.
Successfully removed 'Microsoft.Net.Http 2.2.29' from Project 1.
Reinstalling 'log4net 2.0.8' in project 'Project 3'.
Removing 'log4net 2.0.8' from Project 3.
Successfully removed 'log4net 2.0.8' from Project 3.
Uninstalling 'log4net 2.0.8'.
Successfully uninstalled 'log4net 2.0.8'.
Reinstalling 'Microsoft.Bcl 1.1.10' in project 'Project 3'.
Removing 'Microsoft.Bcl 1.1.10' from Project 3.
Successfully removed 'Microsoft.Bcl 1.1.10' from Project 3.
Uninstalling 'Microsoft.Bcl 1.1.10'.
Successfully uninstalled 'Microsoft.Bcl 1.1.10'.
Reinstalling 'Microsoft.Bcl.Build 1.0.14' in project 'Project 3'.
Removing 'Microsoft.Bcl.Build 1.0.14' from Project 3.
Successfully removed 'Microsoft.Bcl.Build 1.0.14' from Project 3.
Uninstalling 'Microsoft.Bcl.Build 1.0.14'.
Access to the path 'C:\Users\path-to-project\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.Tasks.dll' is denied.
Access to the path 'Microsoft.Bcl.Build.Tasks.dll' is denied.
Successfully uninstalled 'Microsoft.Bcl.Build 1.0.14'.
Reinstalling 'Microsoft.Net.Http 2.2.29' in project 'Project 3'.
Removing 'Microsoft.Net.Http 2.2.29' from Project 3.
Successfully removed 'Microsoft.Net.Http 2.2.29' from Project 3.
Uninstalling 'Microsoft.Net.Http 2.2.29'.
Successfully uninstalled 'Microsoft.Net.Http 2.2.29'.
Attempting to resolve dependency 'System.AppContext (≥ 4.1.0)'.
Update-Package : 'System.AppContext' already has a dependency defined for 'System.Runtime'.
At line:1 char:1
+ Update-Package -reinstall
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Update-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.UpdatePackageCommand

我尝试以管理员身份运行VS 2010,但没有运气。有人可以帮忙吗?感谢。

0 个答案:

没有答案