How do I know if platform projects also require a NuGet package - nuget

In my solution I have a PCL project and two other projects, each for different platforms.
Sometimes a NuGet package used in PCL require installing it to the platform project as well, otherwise things will crash at runtime.
When I install the NuGet package, how do if it's also required to install it to the platform projects?
For example, it's not clear to me if Microsoft.Net.Http requires also installation in Xamarin Android project or not. This is just an example.
Or, I don't know if SQLite.Net-PCL requires it to be installed on platform projects as well.

Things you can do:
Read the documentation provided by the NuGet package author. Either from a project web site or in the description for the NuGet package.
Use your favourite search engine for examples of how to use that NuGet package.
If there are multiple NuGet packages that are named after the platform then that gives you an idea that the PCL NuGet package might not work in the platform specific project.
Have a look inside the NuGet package using something like the NuGet Package Explorer available on Windows. If the NuGet package has lib directories that are platform specific as well as a PCL directory then it will need to be installed in the platform specific project.
Run your application and see if it works.
Taking Microsoft.Net.Http as an example. The documentation does not really say explicitly. If you search the internet you can find a blog post or two that mentions that you have to install it into your platform specific project.
If you take a look inside the Microsoft.Net.Http NuGet package you can see it has several lib directories:
There are platform specific directories, such as MonoAndroid and Xamarin.iOS10 as well as PCL directories, such as portable-net45+win8. This suggests you should install it into all your projects.

Related

Nuget pack does not include external package source

I have written a little library for Sitecore(a CMS product) which means my library depends on Sitecore. Sitecore, the company, have recently made their product available as nuget packages. However they have chosen to host their own nuget package source.
When I use nuget spec/pack myLibrary.csproj to generate a nuget package, only the nuget packages from the official package source are included as dependencies.
Is it possible to include dependencies from another package source in nuget packages?
Or maybe I should ask, how do you go about creating packages from alternative package sources ?

What's the easiest way to check nuget package platforms?

I know name of nuget package in official nuget gallery. How can I check on which platforms it's avaibale, e.g full .net, silverlight, windows store apps, universal platform, etc..?
On Windows I normally use the NuGet Package Explorer which will download the NuGet package and show you its contents. The frameworks it supports are shown in the lib directory inside the NuGet package.
You can also just download the NuGet package from NuGet and unzip it.

Difference between Chocolatey and NuGet

Is Chocolatey a higher version of NuGet or a different package manager? Where should I put my open source application? NuGet or Chocolatey?
NuGet is designed to allow you to easily add code libraries to your project. Things like JSON.NET, Entity Framework, etc.
Chocolatey is actually built on top of the NuGet package system, but it is designed to fill a different need. Chocolatey wraps up applications and other executables and makes it easy to install them on your computer. For example, tools like Git, Notepad++, etc. can be easily installed with a command like cinst git.
https://chocolatey.org/packages has a list of all the applications that can be installed.
If you have an open source project which is a library that is to be used in other developers' projects, then you should submit it to NuGet.
If it is an application that users would normally install, then create a Chocolatey package that users can easily install and update from the command line.

NuGet - Newbie issue on large enterprise system

I just inherited a large enterprise system that appears to use NuGet.
I have just read the basics on what NuGet is so pardon the simpleness of my questions.
Is there a way to tell NuGet to update and install all the packages needed to run the system? I am right now running and seeing what fails then guessing what NuGet packages are missing.
(No, there was no documentation in the enterprise system or many code comments, ugh)
From the package manager console try Update-Package –Project ProjectName
Visual Studio -> Tools -> Library Package Manager -> Package Manager Console
http://nuget.codeplex.com/wikipage?title=Updating%20All%20Packages
If the solution is configured to enable Nuget Package Restore you could also just delete the packages folder and rebuild all which would get everything that you needed. If you need to worry about javascript, configuration, etc... I would try the Update-Package route

How can I add libraries to Xamarin Mono for Android project in VS2010?

I am working on a mono for Android application (my very first) that consumes a web api. In the documentation at xamarin.com there are examples on using different libraries such as RestSharp and Json.Net.
However, when I try to install these libraries via Nuget in my VS2010 project it failes with the following message:
Install failed. Rolling back... Could not install package
'Newtonsoft.Json 4.5.9'. You are trying to install this package into a
project that targets 'MonoAndroid,Version=v2.2', but the package does
not contain any assembly references that are compatible with that
framework. For more information, contact the package author.
How can I include such libraries in my project?
Thanks in advance.
Erwin
This error message indicates those libraries are not compatible with Mono for Android. You should ask the manufacturer of the libraries if they have a MfA compatible version. If you have the source code of the libraries you could also try to make a MfA library, using linked source files, yourself.
Not sure if you've tried this but if you're using xamarin studio and right click the component folder in your Android app project choosing add component should be able to solve your problem. This will add a reference to the component that is added. Components seem like they are mono compatible packages and what's good for your case is that there are components for both RestSharp and Json.Net:
https://components.xamarin.com/view/restsharp
http://components.xamarin.com/view/json.net/