Scripting development environment

Recently, I installed and configured my new development computer. Manual application installation and configuration take a lot of time. In the Linux (Ubuntu) world you can use apt-get to script application installation, but for configuration can backup dotfiles on the old machine and restore on the new. Luckily there are some tools which will help you do same on Windows.

Install applications with Chocolatey

For application installation, you can use Chocolatey. It is a tool like apt-get on Linux (Ubuntu) and has lot of different applications which are used for developers. For example, Notepad++, Atom, GitHub for Desktop etc.

First, install Chocolatey. I have created separate Powershell script file for it - installChocolatey.ps1:

iex ((new-object net.webclient).DownloadString(''))

Then I created a backup.ps1 script to create a list of applications I already installed. It creates the list as a Powershell script which can be used to restore applications. backup.ps1 lists all installed applications, parses the output, creates Chocolatey install command for each application and outputs everything into restore.ps1 file:

choco list -l -r | foreach { "choco install " + ($_).Split("|")[0] } > restore.ps1

Generated restore.ps1 for all my applications looks like this:

choco install 7zip
choco install 7zip.install
choco install Atom
choco install autohotkey.portable
choco install cdex
choco install chocolatey
choco install ConEmu
choco install DotNet4.5
choco install fiddler
choco install filezilla
choco install github
choco install grepwin
choco install imagemagick
choco install
choco install irfanview
choco install kdiff3
choco install libreoffice
choco install nodejs
choco install nodejs.install
choco install notepadplusplus
choco install notepadplusplus.install
choco install NuGet.CommandLine
choco install
choco install pdf24
choco install ReSharper
choco install resharper-platform
choco install sumatrapdf
choco install sumatrapdf.commandline
choco install sumatrapdf.install
choco install synkron
choco install terminals
choco install vcredist2010
choco install vim
choco install vlc

Now I can use restore.ps1 on my new computer to install all the packages. Note that this script prompts for running scripts for each application to install. If you want to skip it, generate choco install command with "-y" parameter.

Configure IIS using Powershell and Chocolatey

For EPiServer development, I use full IIS instead of IIS Express, but it requires proper configuration. It is hard to remember what settings and what features are required when setting it up. So it is better to use Powershell script for it:

Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpCompressionDynamic
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpCompressionStatic
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpRedirect
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpTracing
Enable-WindowsOptionalFeature -Online -FeatureName IIS-BasicAuthentication
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WindowsAuthentication
Enable-WindowsOptionalFeature -Online -FeatureName IIS-DigestAuthentication
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ClientCertificateMappingAuthentication
Enable-WindowsOptionalFeature -Online -FeatureName IIS-IISCertificateMappingAuthentication
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebSockets
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET45 -All

# requires chocolatey to be installed first
choco install webpi

The last command installs Web Platform Installer (WebPI). I need it for one feature - Url Rewriter. Unfortunately, Url Rewriter has to be installed manually using WebPI. A future version of Chocolatey will be able to install WebPI features too.

Backup/restore of Git configuration

Another configuration I want to backup is .gitconfig. On Windows it is usually stored in C:\Users\MyUsername. To backup .gitconfig, just use Copy-Item Powershell:

Copy-Item C:\Users\MyUsername\.gitconfig $PSScriptRoot

It will copy .gitconfig into the same folder where the script is located.

Use the same Copy-Item to restore it:

Copy-Item $PSScriptRoot\.gitconfig C:\Users\MyUsername

Same way it is possible to backup and restore any configuration file.

Where to store scripts and configuration?

I am using OneDrive to store all my scripts and backed up configuration. It is available in Windows after installation and automatically syncs between all my computers. All scripts are available when Windows installation is done.


While a lot of applications can be installed using Chocolatey, there are a lot of applications which still are not available. Also, I won't install Visual Studio and SQL Server using Chocolatey unless I could provide my configuration in a script.