Friday, October 18, 2013

Tips and Tricks on NuGet Packaging for .NET Developers

Hi,

Recently i have the chance to work NuGet, NuGet is an open source Packaging Server and set of tools that you can use to package your work within an organization for distribution or publicly upload your packages to nuget.org to be utilized by all developers.

First, You need to create a website to be accessible by all developers, and then upload or install NuGet server package to it. NuGet Server at the end of the day is a website that holds all your packages.

To host your NuGet Packages in a server:

1) Open your VS 2012 or 2013 and then create an empty web application.
2) Open the Package Console window and install-Package NuGet.Server, this command will install all server components.
3) By Default, you can once you know how to create nuget packages, you need to push it to the packages folder that will be created for your once you install the NuGet Server packages.
4) There are some cool features once you open the web.config, such as the key you need to publish nuget packages.
5) Basically, that's all from the server perspective.

Second, you need to know how to author or design nuget packages, what you need to do, install the Nuget Package Explorer from this url: http://npe.codeplex.com/

Once you install this ClickOnce Windows Application, you will be able to create, design and deploy nuget to the server we just mentioned earlier.

Some tips to create nuget packages using NuGet Package Explorer:
1) You have to set all your dlls in the lib folder, since all these dlls will be added to the references once you install the package.
2) To add the lib folder to your package, right click on the right pane and then select lib folder.
3) You can add dlls to your lib folder by dragging and dropping the dlls to the lib folder in the right pane.
4) You can set any content under content folder such as: images or any required files are needed for any application to utilize your nuget packages.

5) Under lib folder you can different target .NET frameworks such as: .NET 4.0, .NET 4.5



6) The nuget is referring to the target .NET frameworks as follows: net40 to refer to .NET 4.0 and net45 referring to .NET 4.5.
7) Once you save all your referencing dlls, content and .net & nuget packages dependencies, you just need to save the nuget file and then from the file menu item publish to the nuget server.
8) You can even add powershell files when you install, un install and when every time you open VS project which is the purpose of init.ps1.



NuGet Documentation: http://docs.nuget.org/

Hope this helps, let me know if you have any questions.


No comments: