Tuesday, September 9, 2014

Use NuGet with SharePoint

Recently, while working on creating some custom features for SharePoint 2013, I got a bit of frustration trying to make a NuGet package work with SharePoint.
While the Nuget package was installed and didn't give any error in the code, at run time it was either not working at all but not showing any error, or giving a missing assembly error.
I, then found out that it was because the package created by the NuGet manager was not linked to the package that is created with the WSP and I had to add the library reference manually.
Here's how:

  1. Add the NuGet package you wish to use:

        


  2. You will notice that the dll is added to your references and is also added to the package


  3. That, however, will not be added to the SharePoint package, so let's add it manually





    In the popup Window, click the "Browse" button and make sure you browse to the current project, select the right package and add the right assembly.  














  4. And, Finally save the change you just made


  5. From this point on, the NuGet Package should work with no issue in your SharePoint project.

Hope this was helpful.