无法卸载/重新安装的NuGet包 [英] Can't uninstall/reinstall NuGet package

查看:3012
本文介绍了无法卸载/重新安装的NuGet包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了我的项目与Visual Studio Express的2012年,添加了一些C#代码,并成功编译/部署到模拟器。在某些时候,我决定,我想用JSON东西,我发现我应该使用Json.NET框架,这是的可作为的NuGet包。我加入这个框架成功地使用命令安装封装Newtonsoft.Json



我试图安装更新其中MSVC提供两天前,并安装失败,留下我无法再次打开我的项目。重新安装MSVC没有帮助,所以我最终的Windows还原到以前的状态。我能够再次打开我的项目,我想重新安装的NuGet包(不知道它是安装在项目中,的的MSVC)。它给我的错误后安装,所以我试图卸载一切从包控制台



长话短说:




  • 的NuGet包控制台说:没有安装包当获取封装

  • 运行安装封装Newtonsoft.Json 再次给我的错误


    Newtonsoft.Json 5.0.6无法安装。您尝试在一个项目中引用安装此包的WindowsPhone,版本= V8.0,包但不包含此框架


    兼容组件

  • 管理的NuGet包对话框显示的任何软件包下的已安装,但是在网上包,JSON包装上市,并标记为已安装(所以我不能尝试安装它)



现在,我完全丧失。我不知道如何正确地安装包,也不知道怎样去正确地将其删除。是我的项目文件坏了吗?我怎样才能修复它?







现在它会变得更令人困惑。我刚刚更新的NuGet包管理器(不MSVC虽然),并试图重新安装Json.NET。




  • 在对话框中,它仍然是在已安装

  • 在网上包没有显示列出它已不再是标记为安装,但点击安装只是做的没有

  • 获取封装在控制台中显示为安装包

      PM>获取封装

    ID版本说明/发行说明
    - ------- -------------------- -----
    Newtonsoft.Json 5.0.6 Json.NET是.NET


  • 试图与'卸载封装Newtonsoft.Json给包Newtonsoft.Json找不到


  • 卸载
  • 在我的项目文件夹中,我可以看到在包一个Newtonsoft.Json.5.0.6子文件夹目录



我是不是应该从头开始,并创建一个新的项目? :/






packages.dgml的内容:

 <?XML版本=1.0编码=UTF-8>?; 
<的DirectedGraph GraphDirection =LeftToRight的xmlns =http://schemas.microsoft.com/vs/2009/dgml>
<节点/>
<链接/>
<类别>
<类别ID =Projekt的/>
<类别ID =一揽子贷款/>
< /类别和GT;
<样式和GT;
<风格的TargetType =节点GROUPLABEL =Projekt的ValueLabel =真>
<条件表达式=HasCategory('Projekt的')/>
< setter属性=背景VALUE =蓝/>
< /样式和GT;
< /样式>
< /&的DirectedGraph GT;


解决方案

在您的解决方案或项目,你会发现一个名为 packages.config 。打开这个文件,你会看到所有包的NuGet 已安装。



该文件将是这个样子:

 < XML版本=1.0编码=UTF-8>? 
<套餐及GT;
<包ID =Json的版本=2.0.3targetFramework =net45/>
< /包>

只需删除你的包线并保存文件。

 <?XML版本=1.0编码=UTF-8>?; 
<套餐及GT;
< /包>



然后运行的NuGet 再次,它应该安装



JSON.NET的NuGet包应该只是了Windows Phone 8.0的项目工作。在VS2012的NuGet Manager添加它拉在JSON.NET的WP7版本。 (packages\Newtonsoft.Json.4.5.10\lib\sl3-wp\Newtonsoft.Json.dll)



JSON.NET现在也可作为便携式类库,你可以从WP8消耗(提供的NuGet或源代码形式)



编辑:的NuGet的最新版本有一个卸载。



VS 2013:在溶液中,用鼠标右键单击参考和管理的NuGet包,你会发现在左上角安装的软件包。选择包和卸载选项将可用



VS 2015年:在溶液中,用鼠标右键单击参考和管理的NuGet包,发现在已安装标签右上方。将鼠标悬停在包和X将出现卸载。


I've set up my project with Visual Studio Express 2012, added some C# code, and successfully compiled/deployed to emulator. At some point I decided I want to do something with JSON, and I found that I should use the Json.NET framework, which is available as a NuGet package. I have added this framework successfully using the command Install-Package Newtonsoft.Json.

I tried to install an update which MSVC offered two days ago, and the installation failed, leaving me unable to open my project again. Reinstalling MSVC didn't help, so I ended up restoring Windows to a previous state. I was able to open my project again, and I wanted to reinstall the NuGet package (not knowing it is installed inside the project, not MSVC). It gave me errors upon installing, so I tried to uninstall everything from package console.

Long story short:

  • Nuget package console says "no packages installed" when Get-Package
  • Running Install-Package Newtonsoft.Json again gives me the error

    Newtonsoft.Json 5.0.6 could not be installed. You try to install this package in a project referencing "WindowsPhone,Version=v8.0", the package however does not contain assemblies compatible with this framework

  • The "Manage NuGet" packages dialog shows no packages under "installed", however in the online package, the json package is listed and marked as installed (so I cannot try to install it)

Now I'm completely lost. I don't know how to install the package properly, nor how to remove it properly. Is my project file broken? How can I repair it?


[edit] Now it gets even more confusing. I've just updated the NuGet package manager (not MSVC though), and tried to reinstall Json.NET.

  • In the dialog it's still not shown under "installed"
  • In the online packages list it is no more marked as installed, but clicking "Install" just does nothing
  • Get-Package in the console shows the package as installed

    PM> Get-Package
    
    Id                             Version              Description/Release Notes                                                                                                                                                                                            
    --                             -------              -------------------------                                                                                                                                                                                            
    Newtonsoft.Json                5.0.6                Json.NET is a popular high-performance JSON framework for .NET
    

  • Trying to uninstall with `Uninstall-Package Newtonsoft.Json" gives "The Package 'Newtonsoft.Json' could not be found"

  • In my project folder I can see a "Newtonsoft.Json.5.0.6" subfolder in the packages directory

Should I just start over from scratch and create a new project? :/


Contents of packages.dgml:

<?xml version="1.0" encoding="utf-8"?>
<DirectedGraph GraphDirection="LeftToRight" xmlns="http://schemas.microsoft.com/vs/2009/dgml">
  <Nodes />
  <Links />
  <Categories>
    <Category Id="Projekt" />
    <Category Id="Paket" />
  </Categories>
  <Styles>
    <Style TargetType="Node" GroupLabel="Projekt" ValueLabel="True">
      <Condition Expression="HasCategory('Projekt')" />
      <Setter Property="Background" Value="Blue" />
    </Style>
  </Styles>
</DirectedGraph>

解决方案

In your Solution or Project you will find a file called packages.config. Open this file and you will see all the packages that NuGet has installed.

The file will look something like this:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Json" version="2.0.3" targetFramework="net45" />
</packages>

Simply delete the line of your package and save the file.

<?xml version="1.0" encoding="utf-8"?>
<packages>
</packages>

Then run NuGet again and it should install.

The JSON.NET NuGet package should just work with a Windows Phone 8.0 project. Adding it in VS2012 NuGet manager pulls in the WP7 version of JSON.NET. (packages\Newtonsoft.Json.4.5.10\lib\sl3-wp\Newtonsoft.Json.dll)

JSON.NET is now also available as a Portable Class Library which you can consume from WP8 (available in NuGet or in source form).

EDIT: The latest version of NuGet has an uninstall.

VS 2013: In the solution, right click on References and Manage NuGet packages, you will find "Installed Packages" in the upper left hand corner. Select the package and an uninstall option will be available.

VS 2015: In the solution, right click on References and Manage NuGet packages, find the "Installed" tab in the upper right. Hover over the package and the "X" will appear to uninstall.

这篇关于无法卸载/重新安装的NuGet包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆