Create a Windows development enviroment with Packer, Vagrant & Chocolatey
A general development environment for Windows. It is also worth noting that I use this on a daily basis, including on the job.
If you answered yes to any of these questions, then this workflow might be for you.
On your local machine, run the following from an elevated command prompt. Do not run these commands from a PowerShell prompt.
Install Chocolatey
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
Install Vagrant
cinst vagrant -y
Install Git
cinst git.install -y
Free - You need to install this even if you plan on using VMware Workstation
cinst virtualbox -y
Not Free - VirtualBox works great. If you prefer VMware Workstation, you also need to secure the Vagrant + VMware plugin.
cinst vmwareworkstation -y
Clone repo.
git clone https://github.com/PioneerCode/pioneer-windows-development-environment.git
Vagrant requires Boxes. If you don't already have a Windows Box, there are a few different ways you can get one.
Once you have secured your box, navigate to it.
cd {path-to-box}
Add your Box to Vagrant
vagrant box add {name-of-box} {path-to-box.box}
Verify your Box is in Vagrant
vagrant box list
In the pioneer-windows-development-environment repo, there is a file called Vagrantfile. Open it up and ensure the following line matches the name you provided above.
config.vm.box = {name-of-box}
Depending on what you want to be installed coming out of the gates, you might want to take a quick look at the provision scripts located in the scripts folder. Most of what is needed for our entire stack is already configured inside these files. That being said, you might have some personal preferences. Open each up to take a quick look and make any adjustments you see fit.
Typically, you would want to at least open up install-programs.ps1 and select the appropriate version of Visual Studio to be installed. As a default, Visual Studio 2017 Enterprise edition is provisioned.
Some people will want to run scripts as provisions of vagrant up
, others might want to move the script files to their new VM and run them at will. By default, the Vagrantfile is set to run a few scripts that I know I will always need to be run. If you prefer, you can comment those provision out and uncomment the "file" provision. The "file" provision will instead move the scripts to the c:\users\vagrant\documents\script
. This will allow you to run them whenever you see fit.
Depending on your environment, run one of the following. Default == VirtualBox.
vagrant up
vagrant up --provider vmware_workstation
vagrant up --provider vmware_fusion
vagrant up --provider hyperv
This will configure and create, if not already done, a guest machine for you. Depending on what you are installing, this will take anywhere from a minute (empty guest) to about 30 mins (default provisions) to complete.
cinst -y sql-server-management-studio
after the initial provision.