How to use Sitecore Nuget
If you have ever used NuGet within any of your Visual Studio projects you will know how easy it is install 3rd party dependencies, update them and bring new developers onto a project, Wouldn't it be useful to take advantage of NuGet in Sitecore.
With the power of Nuget and Powershell you can add files to your solution, add files to the inetpub folder containing your website and best of all insert items directly into the master database of your Sitecore instance.
To create a custom NuGet Package i use NuGet Package explorer. Its a friendly GUI for creating, updating and publishing NuGet packages (.nupkg) or a public or private NuGet repository.
How To Create A Sitecore Nuget Package
- Download NuGet package explorer. http://nuget.codeplex.com/releases/view/59864
- Open the sample Sitecore Nuget package. Sitecore.NuGet.Sample
Open NuGet Package
Sitecore NuGet Package
- Edit the metadata for the package using the edit button on the left.
- The content folder if for any items (css, c# files, java script etc.) you want to add to your solution. The files will be added to reflect the folder structure here.
Content Node for adding to the VS solution
- The tools folder is where the Powershell and DLL for Sitecore NuGet are contained. You can extend the powershell for pre-install and post-install events.
- Next we want to serialise Sitecore items to include them in the package. Within the Sitecore content editor navigate to the items you want to serialise and press the Serialize Tree button to serialise the content item and all decendants, do this for all items you want to include in your package.
Serialise Sitecore Items
- The items are then serialised to the disk. Navigate to your sealisation folder. (C:\inetpub\wwwroot\(ProjectName)\Data\serialization) Copy the serialised items you need into the serialsation folder in NuGet.
- Save or publish your package to your NuGet repository
Using Your NuGet Package
- Install Sitecore Rocks
- Create a connection to your Sitecore instance (Make sure the connection is outside the folder Sitecore NuGet can't see the connection in here)
- Add a connection between your project and the Sitecore Rocks connection
Connect to Sitecore
- Now you can install your NuGet package directly into your solution and Sitecore instance
Nuget Package Installer
- Powershell and Sitecore rocks will now copy any files into your project and push your serialised items into the master Sitecore database