« Archives in May, 2013

Turn any Sitecore package into a NuGet package

I recently posted this idea on Twitter:

And it didn’t take me that long to actually implement it. Follow these steps to turn any Sitecore package into a NuGet package and share it with the world.

  1. Download the CreateSitecoreNuGetPackage.exe file here or build it yourself with the code from GitHub.
  2. Put the files “Sitecore.Kernel.dll” and “Sitecore.Zip.dll” in the same folder.
  3. Create your package in the Package Manager and export the ZIP file.
  4. Run the following command from the command line:
    CreateSitecoreNuGetPackage [PATH_TO_SITECORE_PACKAGE]
  5. Use the NuGet Package Explorer to open the generated  .nuspec file and improve the metadata if needed.
  6. Publish the package to a repository, like nuget.org.

Now, everyone will be able to install/uninstall your package through NuGet. Remember that you need to install Sitecore Rocks and attach your project before installing the package.

Some links to pages that helped me creating this:

I will be very interested to hear your feedback, as I haven’t been able to test this very well. If this utility catches on, I might make a version that you can use from the package manager directly.

Happy NuGetting :-P

CompiledDomainModel 1.0 released!

This was a little overdue; my Sitecore code generation module, CompiledDomainModel, has been used in many projects and the code has matured enough to justify a 1.0.0.0 version number. A very important addition was made in this release.

Release 1.0.0.0:

  • Added “Platform Mode”, that can be used if generated code needs to be in separate files (e.g. when there are multiple DLL’s where generated code is needed)
  • NuGet support added

Platform Mode

This is a feature that has been requested by several people. If you have multiple projects or logic that is used in several DLL’s, then you need a way to divide the generated classes up into multiple files.

To make this possible, you should first check the “Platform Mode” checkbox on the settings item (/sitecore/system/Modules/CompiledDomainModel/Settings):

Note that the wrapper classes need to be resolved globally when using the platform mode. To make that possible, there is a dependency on the module itself. So you can’t use the “Remove dependencies” function when you want to use the platform mode.

If you generate the code now, you’ll see that a comment is generated:

As is explained, you must now make url’s to generate code that is specific to your project. In this case, you could generate code for the platform project and the specific “SomeProject” project. Using the following url’s, you can do that:

  1. http://sitecoredemo/sitecore/shell/Applications/CompiledDomainModel/CodeGenerator.aspx?platformsets=Core|PlatformTemplatesSet|PlatformFixedPaths
  2. http://sitecoredemo/sitecore/shell/Applications/CompiledDomainModel/CodeGenerator.aspx?platformsets=SomeProjectTemplatesSet|SomeProjectFixedPathsSet

These url’s will only generate the code for the DomainObjectSets and FixedPathSets (check the documentation for an explanation about these sets) that are referenced in the url.

NuGet support

You can now install CompiledDomainModel through NuGet. I based the package on this excellent article.

Steps:

  1. You need to have Sitecore Rocks installed in Visual Studio
  2. You need to connect your project to your Sitecore website
  3. Open the Package Manager Console and run Install-Package CompiledDomainModel

Of course you are not required to install CDM this way. You can still use the regular package on the Releases page.

Happy CDM-coding!

UA-4216957-1