1

I recently asked the question about the deployment of certain items from one environment to another. But the question I have now is how to deploy the site modules? I want to choose the path of making the packages and use the items inside the packages to deploy them. Is it possible to use this with site modules or is it not?

What is the solution here when it comes to site modules?. Should I use them with packages or not?

8
  • Are you asking about any custom modules? Because in each environment OOTB modules will be installed automatically. Commented Apr 11, 2022 at 9:23
  • @GauravAgarwal Hello. I am just asking about the default site modules. So that means when I deploy some item that is inside the module that currently does not exist on the environment, it would automatically install that module or?
    – Samke11
    Commented Apr 11, 2022 at 9:25
  • If you are installing Sitecore, then the module should already be there, you need to see if it is inherited into your Tenant. Commented Apr 11, 2022 at 9:28
  • @GauravAgarwal I do not think we understand eachother very well here. I do not have this module inside the, lets call it "Environment 1", but I have it in "Environment 2". How to deploy it in "Environment 1". And yes, this is my custom module actually, that I made
    – Samke11
    Commented Apr 11, 2022 at 9:32
  • @Samke11 so you have created a module, called for example Navigation which has some renderings inside /sitecore/layout/renderings/feature/navigation and some templates inside /sitecore/templates/feature/navigation and you want to transfer those items from one environment, let's say you local dev to some shared test environment? Commented Apr 11, 2022 at 11:38

3 Answers 3

2

There are couple of ways to approach that.

Sitecore allows you to create a package definition as an XML file and then build a package from that definition. You can access package definition from the "Start menu" in the Desktop view and then go to Development Tools and Package Designer.

If you want to create the package:

  1. Create the package definition using the designer or load it if it already exists
  2. If you are creating package definition add all the trees your module consists of (eg. /sitecore/layout/renderings/feature/navigation and /sitecore/templates/feature/navigation) so all the child items are automatically included
  3. Build & download the package

If you want to automate the whole process you can use PowerShell script to create packages:

$package = New-Package "Packing in Powerful Ways";
# Set package metadata
$package.Sources.Clear();

$package.Metadata.Author = "Your Name";
$package.Metadata.Publisher = "Your Company";
$package.Metadata.Version = "1.0";
$package.Metadata.Readme = 'Some description'

# Add contnet/home to the package
$source = Get-Item 'master:\layout\renderings\feature\ModuleName' | New- 
ItemSource -Name 'Module Name Renderings' -InstallMode Overwrite
$package.Sources.Add($source);

# Save package
Export-Package -Project $package -Path "$($package.Name)-$($package.Metadata.Version).zip" -Zip

# Offer the user to download the package
Download-File "$SitecorePackageFolder\$($package.Name)-$($package.Metadata.Version).zip"

Script will be much more powerful as you can adjust it to run for every module and can be triggered using PowerShell remoting.

See the Sitecore PowerShell docs for more information.

Downsides of using the packages

Using package might seem easier but remember that packages are binary files and are hard to version. Serialization (tools suggested by @Rauman Gupth) allows you to convert items into text format which are easier to version.

4
  • Thank you for explanation. So do you suggest for me to just add the items from the Renderings, Branches and Templates, from that specific module, to the package folder and then upload them to another environment?
    – Samke11
    Commented Apr 11, 2022 at 11:56
  • @Samke11 what do you mean "to the package folder" Commented Apr 11, 2022 at 11:57
  • I mean should I add these items to the "package definition" with designer?
    – Samke11
    Commented Apr 11, 2022 at 13:11
  • @Samke11 yes, I have updated the list of steps in my answer Commented Apr 11, 2022 at 16:04
2

When you create a custom module in Sitecore, all the items created (rendering definition item, rendering parameters template, data source templates, and branches) should be part of Serialization tool (Unicorn/TDS/SCS). So that you can commit these items to your source control and on other environments you can simply sync these items. No need to re-install the module on other environment after syncing these items.

SXA modules are stored in the Feature or Foundation folder:

  • /sitecore/System/Settings/Foundation/Experience Accelerator/

  • /sitecore/System/Settings/Feature/Experience Accelerator/

0

You can achieve this functionality through two ways:

  1. Unicorn or TDS
  2. Create a package

Explanation :

Unicorn or TDS : Whenever you create a module all its items will add in serialization folder if you have serialized that module.

You can add Unicorn in your project. With the help of Unicorn you can commit/push your changes in Team explorer in Visual Studio to higher environment (Test or QA etc.) and go to the unicorn page by using this path https://testsite/unicorn.aspx and sync your changes.

enter image description here

Reference :

https://sitecorediaries.org/2020/08/22/how-to-setup-unicorn-for-helix-based-sitecore-project/

Create a package : You can create a dynamic package(can use multiple time without change the script) through PowerShell script and add path of each module through prompt.

First approach is the best approach if you need to sync multiple time in higher environment.

Your Answer

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

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