UWP – NuGet


NuGet is a package distribution system, it’s very easy to add new functionality to your project using NuGet. You can add controls, helpers, converters, … .
These packages can be added to your solution (so it’s available to all projects in the solution) or per project.

For an example, we want to add som JSON reading functionality to our project.
To do this, right-click your project and click on ‘Manage NuGet Packages…’


Now you can browse, view the installed packages and updates for the packages.
Search for json, click on Newtonsoft.Json and on the right click on Install.


In the Output panel you will see it starts installing the package.


That’s it! The package is now installed and ready to use.
When the package is using licenses or uses other packages, a pop-up will show asking for your permission.

Now Newtonsoft.Json is ready to use, so you can start serializing/deserializing JSON.

 Product product = new Product();

product.Name = "Apple";
product.ExpiryDate = new DateTime(2008, 12, 28);
product.Price = 3.99M;
product.Sizes = new string[] { "Small", "Medium", "Large" };
string output = JsonConvert.SerializeObject(product);

//{ // "Name": "Apple",
// "ExpiryDate": "2008-12-28T00:00:00",
// "Price": 3.99,
// "Sizes": [
// "Small",
// "Medium",
// "Large"
// ]

Product deserializedProduct = JsonConvert.DeserializeObject<Product>(output);

You can also browse all the packages on the NuGet website.

One thought on “UWP – NuGet

Leave a Reply

Your e-mail address will not be published. Required fields are marked *