Following the Helix modular architecture, my solution is divided into a large amount of separate projects. To deploy the solution as a single package, we need to package all assets, configuration files, views aso. from all the projects into a single deployment package.

Habitat is using gulp for this purpose, however I prefer limiting the amount of dependent tools to a minimum. We are already using Powershell as a tool in our deployment setup, thus this would be the preferred tool for this task also.

Is there any Powershell port of the Habitat gulp tools available? Does any of you have experience with another approach for deploying solutions based on Helix?

  • I have updated my answer with some example code. Commented Oct 7, 2016 at 13:27

1 Answer 1


You might want to consider psake. It is a task based build system written in Powershell.

A good starting point would be this piece of code:

# Let's define layers here
$layers = @( "Foundation", "Feature", "Project" )
# These folders we want to copy to our target
$foldersToCopy = @( "Views", "bin", "App_Config" )

# This is the default task which will run if no tasks are specified
task default -depends CreateReleasePackage

# This is the main task of the scrip - it creates release package
# It relies on Clear to make sure all the garbage from previous run is out
task CreateReleasePackage -Depends Clear,Prepare,BuildSolution {
    $layers |% {
        Process-Layer $_

# Cleanup task to remove output of the previous run
task Clear {
    if (Test-Path "../target") {
        Remove-Item "../target" -recurse

# Prepare the folders to simplify copying code
task Prepare {
    New-Item -type Directory "../target"
    $foldersToCopy |% {
        New-Item -type Directory "../target/$_"

# If the solution is not built there is a lot of stuff missing
task BuildSolution {
    Exec { msbuild "../Habitat.sln" }

# Function to process Layer, ie. iterate over it's directories
function Process-Layer {
    param( [string]$layer )
    Write-Host "Creating release package for layer: $layer"
    Get-ChildItem ../src/$layer |% {
        Process-Module $layer $_.Name


# This function does all the job - it collects the interesting data from the project and copy it to common folder
function Process-Module {
    param( [string]$layer, [string]$moduleName )

    $foldersToCopy |% {
        $folderName = $_
        $folder = "../src/$layer/$moduleName/code/$folderName"
        # Better check if the folder exists, some modules might not have views or configs
        if (Test-Path $folder) {
            Write-Host "Copying $folder to ../target/$folderName"

            copy-item "$folder/*" "../target/$folderName" -force -recurse -Exclude "Debug"


Now all you have to do is to call a following script from a folder where you have your psake directory:

Import-Module ./psake/psake.psm1

Invoke-Psake ./build.ps1

Note that this is build agains Habitat project and it might be slightly different depending on how your solution is organized

And since you already mentioned powershell it is worth mentioning, that using Sitecore Powershell Extensions you can also automate creation of a Sitecore packages.

You can do this using create-package cmdlet

# Create package
   $package = new-package "Sitecore PowerShell Extensions";

# Set package metadata

   $package.Metadata.Author = "John Doe";
   $package.Metadata.Publisher = "ACME Ltd";
   $package.Metadata.Version = "1.0";
   $package.Metadata.Readme = 'Information about your package'

# Add contnet/home to the package
    $source = Get-Item 'master:\content\home' | New-ItemSource -Name 'Home Page' -InstallMode Overwrite

# 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" 
  • Do you know of any example Helix/Habitat psake build-steps for packaging multiple projects? I don't think we will need Sitecore packages, we are deploying content using Unicorn.
    – Kasper
    Commented Oct 5, 2016 at 7:05
  • No, I don't know of any specific implementation. In my previous company we've been using in-house solution and as far as I remember the task to deploy files from solutions was simple xcopy call with appropriate excludes. I cannot share this unfortunately as this is not public code and we were not using habitat. Commented Oct 5, 2016 at 7:13
  • 4
    This seems a bit off topic (but not enough to relevant a downvote). The psake discussion could make a good answer, but should be beefed up with some example code to show readers how this is relevant. The SPE package generation would be better served in its own Question and Answer, since the sample code does not bear on how to address the posted question. Commented Oct 5, 2016 at 12:12
  • Good point. I will provide some example task when I got back from work. Commented Oct 5, 2016 at 12:15

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.