The Power of Shell – Step by Step until Sitecore 9 developer environment #1

On this post I would like to share something that I’m currently working,
I think that the Infrastructure guys will love it,
But I stated working on that, because I really don’t like to install my environment step by step, again and again,
So it can save some time to setup a development environment when you get a new pc.

The idea is install all things that are requirement for Sitecore.

So lets start with this simple post about pre-requirements for PowerShell itself.

You can download the file form here if you prefer:
0-Powershel Pre-requisites.ps1

And I will try to explain the code here, if you have some question about it you can comment bellow and I will answer it asap

  • First you will need to enable script execution
    you can find more information about script execution policy here

#PowerShell modules need to enable script execution
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force;

  • Second you need to install Chocolatey, basicly it “is a package manager for Windows (like apt-get or yum but for Windows). It was designed to be a decentralized framework for quickly installing applications and tools that you need. It is built on the NuGet infrastructure currently using PowerShell as its focus for delivering packages from the distros to your door, err computer”, I use this to install softwares and tools that we need to install, like SQL Server for exemple,  you can find more information here

#Chocolatey
write-host “Installing Chocolatey module”
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’))

  • “Chocolatey makes installing software very easy with no user intervention. Boxstarter enhances Chocolatey’s functionality and provides an environment that is optimized for installing a complete environment on a fresh OS install, as well as some other specific scenario”,  so I use this to do changes on windows features (https://boxstarter.org/WinConfig) that you will se in the next post.

#BoxStarter depends of Chocolatey
write-host “Installing Boxstarter module”
CINST Boxstarter -y

  • It can be optional, but I like to have it, I have the intent to use this in my future scripts, so, its enable the NuGet features like on VS, you can install modules, create modules and a lot of other things

#Nuget
write-host “Installing NuGet module”
Install-PackageProvider -Name NuGet -Force

  • We need this one to install Sql server, and to configure it, import database and bases and things that Sitecore installation script will do

#Sql Server module
write-host “Intalling Sql Server module”
Install-Module -Name SqlServer -AllowClobber
choco install ssdt17

  • And Finally, Sitecore Installation Framework, and I think that this one don’t need any explanation, its all about Sitecore 9

#SIF
Register-PSRepository -Name SitecoreGallery -SourceLocationhttps://sitecore.myget.org/F/sc-powershell/api/v2
Install-Module SitecoreInstallFramework -Force
Update-Module SitecoreInstallFramework

#confirm installation
Get-Module SitecoreInstallFramework –ListAvailable

If you understood and completed all script steps until here, you are ready for the next step that will be install the tools and software that we will need.

Advertisements

Powershell – How to create a #Sitecore #Helix based Solution

I would like to tell, that I’m working with PowerShell to try optimize development environments for Sitecore Developers, and as my first blog post of this serie,

I upgraded the PowerShell Script that Akshay Sura have made some time ago(see references).
The Ideia is using a script to work with Visual Studio (now 2017 and I think that 2015 too) and create a Solution with directories and projects based on Helix principles.

This script can improve the creation of a New Visual Studio Solution from scratch following Helix recommendations,

To install it, it’s easy:

Step by step:

  1. Download and save the script in a location that you can find, copy the full path of the location that you saved the file
    https://gist.github.com/hedipo/09d1fff5c259e8c4bac0f53c306e1a8f
  2. Open Visual Studio IDE
  3. Open Package Manager Console (View -> Other Windows -> Package-Manager Console)
  4. Type in $profile
  5. Open the location that appeared in Windows explorer.You might not have NuGet_profile.ps1 on this location.

  6. Create one file “NuGet_profile.ps1” (with notepad for example) (if you have ignore it)
  7. Open the “NuGet_profile.ps1” and insert the line below with the full path for your script in my case: “HabitatSolutionScript.ps1”. “D:\Projects\PowerShell\HabitatSolutionScript.ps1”
  8. Save and close “NuGet_profile.ps1”
  9. Restart your Visual Studio IDE and open Package Manager Console
  10. Type in “let” and press “Tab” or you could type in the whole command “Lets-Rumble”
  11. Follow the steps on the command screen

Important things:
– Previously define what Features, Foundations and Projects you want to use. It will facilitate a lot.
– You can refer to this link https://kb.sitecore.net/articles/087164 to get Sitecore .Net Framework compatibility .
– Remember that you need to have .net framework that you want previously installed

References and a video can be find on original Akshay Sura Post:
https://www.akshaysura.com/2017/01/21/habi-what-a-tat-create-a-sitecore-helix-solution-from-scratch-using-powershell/

Upgraded script:
Script can be find on: https://gist.github.com/hedipo/09d1fff5c259e8c4bac0f53c306e1a8f

More about Helix:
http://helix.sitecore.net/