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:
Get-Package
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
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.
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"
packages
directoryShould 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>
Right-click on Project and select Manage NuGet Packages option. Select the Installed tab from NuGet Package Manager dialog and you can see the installed Syncfusion NuGet packages list by giving the Syncfusion keyword in search. Uninstall the Syncfusion NuGet packages which are not required for the project.
Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.
Uninstall a packageIn Solution Explorer, right-click either References or the desired project, and select Manage NuGet Packages.... Select the Installed tab. Select the package to uninstall (using search to filter the list if necessary) and select Uninstall.
Open Visual Studio, go to Tools -> NuGet Package Manager -> Package Manager Settings menu. Click Clear All NuGet Cache(s) button in options dialog then clearing process is started. Once NuGet cache location is cleared, click ok button.
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).
I had the same problem. I wasn't able to re-install my package even after all the package.config modifications. Here what work for me.
In your solution folder there should be a "packages" directory. Open this directory and delete the directory associated with your package.
Done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With