Setting up Virtual Machines Rapidly with Chocolatey
Rationale
As a Mac user I have a virtual machine for my Windows applications (Parallels or in Azure). Every now and then the machine has accumulated so many applications I install for test purposes, that it consumes a large amount of disk space, is slow and the software is outdated. Thus, I destroy the machine regularly and set it up from scratch. In this, the Chocolatey package manager comes in as a great helper. It streamlines the re-installation of my virtual machine.
Recreate a Windows VM
The following shows my steps for recreating virtual Windows machines:
Save the Current State
From your current VM instance …
-
Export all Chocolatey packages (see below)
-
Export the list of all Plugins you have installed for your development environments
-
Remove all the packages from the exported lists, which you don’t need any longer
Note:
At the moment I do not save Application Settings
Setting Up the VM From Scratch
-
Install the base Windows system from CD (or restore it from a backup)
-
Install all pending Windows Updates
-
(Parallels) Install Parallels Tools and activate the shared clipboard
-
Install Chocolatey
-
(Azure VM) Install a means to share data with your remote pc, e.g. NextCloud.
-
Install the Chocolatey packages you have exported previously:
choco install packages.config -y
-
Update all install Chocolatey packages:
choco upgrade all
-
Cleanup:
cleanmgr
Finetuning
- For Docker-Desktop the Windows Subsystem for Linux is required
Appendix
Export Installed Chocolatey Packages
Hint: Upgrade your chocolatey packages first: choco upgrade all
Easy way: ChocolateyGUI
-
Install ChocolateyGUI:
choco install chocolateygui
-
Click the Save button to export all installed packages.
Without ChocolateyGUI
Follow the instructions Ammaar Limbada has published on GitHub: alimbada / ExportChocolatey.ps1
#Put this in Export-Chocolatey.ps1 file and run it:
#.\Export-Chocolatey.ps1 > packages.config
#You can install the packages using
#choco install packages.config -y
Write-Output "<?xml version=`"1.0`" encoding=`"utf-8`"?>"
Write-Output "<packages>"
choco list -lo -r -y | % { " <package id=`"$($_.SubString(0, $_.IndexOf("|")))`" version=`"$($_.SubString($_.IndexOf("|") + 1))`" />" }
Write-Output "</packages>"
Interesting Visual Studio Plugins
- Resharper - installed via Chocolatey
- SpecFlow
- CodeMetrics