2

We need to create NuGet packages for reusable code to be used across our organization.

Each component to be packaged contains dll, configs, and Sitecore items. My doubt is -

  1. Is there any specific structure that we need to follow to package the above resources?
  2. Can we add the Sitecore items package created using Installation Wizard in Sitecore to our NuGet package?
  3. Is there any existing Sitecore NuGet package that we can analyze to get an idea about structuring our package?

Please let me know if anybody has done something similar to this before. We don't intend to use TDS, unicorn, etc for serializing items as we want to make the components reusable among all projects (which may use TDS, unicorn, etc).

Thanks in advance!

1 Answer 1

3

There are different approaches you can use but at a basic level you need somewhere for your site files to go (config/admin pages/css/js etc) and then also somewhere for your dlls to go and an nuspec file.

The structure we use is as follows:

enter image description here

Content - this should be structured in the same way as your Site root folder. e.g /app_config sub folder with other sub folders in it and config inside those. or /sitecore for any sitecore files.

lib - This should contain one or more sub folder for your site with the dotnet version (e.g net461) and then the dlls that are needed.

The nuspec config should look something like this and reference all the files required:

<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
  <metadata>
    <id>Template.Module</id>
    <version>1.0.0</version>
    <title>Template.Module</title>
    <authors>-</authors>
    <owners>-</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>
    some info here about Template.Module
    </description>
    <tags>Template.Module</tags>
  </metadata>
  <files>
    <file src="content\App_Config\Include\Template.Module\Template.Module.config" target="content\App_Config\Include\Template.Module\" exclude="" />
    <file src="lib\net461\Template.Module.*" target="lib/net461" />
    <file src="content\sitecore\admin\Template.Module\Template.Module.aspx" target="content\sitecore\admin\Template.Module\" exclude="" />
  </files>
</package>

Some people also include an Sitecore package inside their nuget package of any Sitecore items of Serialized items to install into Sitecore along with the module. Some Marketplace modules also use this approach.

Bear in mind that if your following Helix principles you will want to structure your modules differently with feature/foundation layers etc. There are some posts on this here:

Sharing Sitecore content as a NuGet package

Creating a custom Sitecore NuGet package containing Unicorn files

You can then host these modules on an internal/private nuget feed if you wish to share them.

There are some github projects where people have already set up a skeleton you could use too: https://github.com/etruong42/Sitecore.NuGet.Skeleton

See my answer here for some more info and links too: Sitecore deployment with new modules

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.