At Sitecore Symposium 2019, Helix 2.0 was announced and released. The Helix documentation provides best practice recommendations when developing for Sitecore. Helix 2.0 provides clarification as well as enhanced examples to help provide developer guidance to Sitecore. To learn more about the principles of Helix see the official documentation at [helix.sitecore.net].

When applying the Helix principles to the implementation of or enhancements to Sitecore Experience Platform, I find one of the most difficult steps is to ensure that my Visual Studio solution and associated file structure is properly setup. The Visual Studio solution leverages a number of solution folders to group projects into the appropriate module/component as well as to show separation of layers.

The corresponding file system structure is similar in the usage of expected folder naming and nesting. It is important to follow this file system structure as many community tools now expect this pattern when developed and shared.

/… /[Module Name] // Module root folder, named after the module (without prefixes) /website // Houses the website code for the module, for example the Visual Studio project with the website business logic or views. /serialization // Contains the serialized data from Sitecore, for example templates, content or security data /tests // Unit or other test types for the module /commerce // Houses the code for the plugin that runs on the Commerce Engine /xconnect // Houses the code for plugins targeting the xConnect website

In example this looks like

As one can see, to create the established solution and file system structure can be very tedious (and possibly error prone). There are a number of community-built tools from leveraging npm and yeoman to Visual Studio Extensions.

A couple of years ago I wrote a PowerShell module to create and manage Helix based solutions. With the updated documentation this felt like a nice time to refactor and update the script. So here is my addition to Helix tooling options. It is PowerShell based, using the DTE Interface as accessible in the Package Manager Console (which is just a PowerShell prompt with added modules and objects) meant to be used directly form within Visual Studio with your solution actively open.

Helix.ProjectCreator.psm1

The code and additional documentation (including some basic installation steps and script) can be gotten from GitHub at https://github.com/gillissm/TheCodeAttic.Helix.PowerShellProjectCreator.

Setup Options

Setup and Configure from Script

To make adaption as easy as possible I’ve simplified setup to the following three steps for you:

Open PowerShell command prompt as Admin. Change the directory to a working/temporary location Enter the following

(Invoke-WebRequest -UseBasicParsing -Uri https://raw.githubusercontent.com/gillissm/TheCodeAttic.Helix.PowerShellProjectCreator/master/ProjectCreatorEasyInstall.ps1).Content | Out-File "ProjectCreatorEasyInstall.ps1" .\ProjectCreatorEasyInstall.ps1

Setup and Use the Simple Manual Process

As an alternate to the above, you can pull the script from GitHub, then load (ie install-module) into Package Manager Console each time you need it with the following steps:

Download (https://github.com/gillissm/TheCodeAttic.Helix.PowerShellProjectCreator/blob/master/HelixProjectCreator.psm1) to your local system in the manner that suits your workflow the best. Each time you wish to leverage the module in Visual Studio you will need to enter the following in the Package Manager Console

Import-Module "C:\MyFiles\Helix.ProjectCreator.psm1"

Using the Script to Manage Helix Solution

Because the script leverages the native DTE Interface of Visual Studio is can be used to create new solutions, as well as modify existing solutions without any additional tweaks to the code.

Confirm Module Has Loaded

The following will allow you to confirm that the module is accessible for usage. This check is most helpful the first time one has used it after leveraging the easy install script.

Get-Module Helix.ProjectCreator -ListAvailable

Create a new Helix Solution

Open Visual Studio as Admin Open the Package Manager Console Create a new Helix based solution by running Invoke-VisualStudioSolution Set the parameter -SolutionName, this will be the name of the VS solution as well the name given to the directory create for the solution

Set the parameter -DirectoryPath, this is the fully qualified path to the parent directory the solution should be created at

Invoke-VisualStudioSolution -SolutionName HelixAttic.Sample -DirectoryPath C:\Code\git-TheCodeAttic\

Add a new module to a solution

Open Visual Studio as Admin Open your Solution Open the Package Manager Console Add new module by running Invoke-NewModule Set parameter -ModuleName to the name of the module/component, this should NOT include the full namespace, as this will be generated automatcially based on solution name

Select a value for -Layer from the provided list (Feature, Foundation, Project) depending on need

Optionally include the -UseUnicorn or -UseTDS flag to setup the corresponding serialization requirements

Invoke-NewModule -ModuleName PageContent -Layer Feature -UseUnicorn

Add a new empty module to a solution

In addition to creating a project with folders and NuGet references, the script can add a blank or empty project with the given name to the solution by including the flag -CreateEmptyProject.

Invoke-NewModule -ModuleName PlaceHolder -Layer Foundation -CreateEmptyProject

See the module file for a listing of all optional parameters, including the ability to set a specific Sitecore version.

Other Cmdlets of interest

Invoke-SerializationProject

Call this to setup Unicorn or TDS project for a given module. When calling, be sure to include the full project name (with namespace).

Invoke-SerializationProject -ProjectName HelixAttic.Sample.Foundation.PlaceHolder -UseUnicorn

Invoke-CreateNewModuleProject

Call this to add an empty project to the solution for a layer, this is the same as calling Invoke-NewModule with the ‘CreateEmptyProject’ flag.

Now go create some awesome Sitecore code with confidence!