For the .Net developer, reinstalling Visual Studio is not far from repaving your machine. Its something almost all of us has had to do. No doubt it gets faster in every version. I remember when VS 2003 would take hours and you had to sit there looking at goofy model engineers and read scrolling marketing text. I already bought the damn product. If you are so awesome why am I sitting here completely unproductive?! Thank god those days are gone, but it still takes a lot longer to install than Minecraft.
About 18 months ago, I joined a new team where we had to work against new Visual Studio builds and reinstalling Visual Studio was AT LEAST a weekly event. I then hunkered down and looked into how to install Visual Studio unattended. Then I created Chocolatey packages for it.
Chocolatey, here to save you from the tyranny of Next…Next…Finish
Look. Just finish. I don’t do Next anymore. There is nothing of value at Next.Its simply a passing, transient WPF form standing between where you are now and your ability to deliver something awesome.
Chocolatey is a great tool every Windows dev and power user should have. Here is how it works:
- I need a tool, lets say fiddler for inspecting HTTP traffic.
- I pop open a command prompt and type CINST fiddler
- I do something else for a minute.
- I have fiddler installed and ready to run.
Chocolatey has almost 1500 software packages that follow this same model. Most are dev tools so the chances are that your tool is in the public Chocolatey feed. You are wasting your time going to the web and searching for a GIT download and reading up on how to install it. Just type CINST GIT and be done with it.
Getting Visual Studio with Chocolatey
Since there are different Visual Studio SKUs (Ultimate, Professional, etc.), there re separate Visual Studio Chocolatey Packages for each. I have created packages for most of them covering versions 2012 and 2013. Go to Chocolatey.org and search for “visual studio ide”. You will see a bunch of them.
If you have Chocolatey, simply run:
CINST VisualStudio2013ExpressWeb
That’s it. Give it 10 to 20 minutes and you have it. Oh you wanted Resharper too? Quit your crying and enter: CINST resharper.
How do I pay for the Non-Express SKUs?
If you work with the professional or ultimate Visual studio SKUs, you likely have the product key. Install Visual Studio via Chocolatey and you will be prompted for your key upon first use. I believe (I could be wrong here) that you have 30 days to enter the key.
How do I specify the Visual Studio features I want installed?
The non-express skus all have at least a half dozen features you can add to the initial download and install. These include some very valuable features like the Web Tooling that brings in CSS and Javascript editing goodness. By default, a Chocolatey flavored Visual Studio install does not install any of these. Most people want either none or just one or two. However, as of today, I have added support for specifying optional features in the Chocolatey install command. It leverages the –InstallArguments parameter. Here is an example:
cinst VisualStudio2013Ultimate -InstallArguments "WebTools Win8SDK"
This installs both the Web tooling features and the Windows 8 Store Apps SDK. Here are all of the available feature names:
- Blend
- LightSwitch
- VC_MFC_Libraries
- OfficeDeveloperTools
- SQL
- WebTools
- Win8SDK
- SilverLight_Developer_Kit
- WindowsPhone80
I didn’t make these names up. They come from the AdminFile SelectableItemCustomization strings.
Uninstalling and Reinstalling
Sometimes we want to start over from scratch and with Visual Studio, the uninstall is not much faster than the install. So that is nice to script as well and Chocolatey has you covered here. The Visual Studio 2013 packages come with uninstallers. So if you wanted to say uninstall and then reinstall in one script, it would look like this:
CUNINST VisualStudio2013Ultimate CINST VisualStudio2013Ultimate
The uninstaller looks through your installed MSI packages for the correct uninstaller and invokes it with instructions to run passively.
Visual Studio loves Rebooting
Here again, things are much better than they were years ago. One can typically install an Express or optionless install of Visual Studio never needing to reboot. However, once you start adding features, in addition to perhaps installing the .Net framework, SQL Server and on and on, a reboot (or a couple) becomes nearly inevitable.
In these cases check out Boxstarter. That’s my little project and I’m proud to say both it and Chocolatey were given a mention in Scott Hanselman's 2014 Ultimate Developer and Power Users Tool List for Windows. Boxstarter provides an environment for invoking Chocolatey packages that is reboot resilient. It also allows you to run them on remote machines and Hyper-V VMs. Have a couple VMs that need Visual Studio? Run:
$c=Get-Credential administrator "VM1","VM2" | Enable-BoxstarterVM -Credential $c -Checkpoint BareOS | Install-BoxstarterPackage -PackageName VisualStudio2013Ultimate –Force
This will run the VisualStudio installer on Hyper-V VMs named VM1 and VM2. If there are pending reboots before the install, Boxstarter will reboot the VM. If you need to install multiple packages (maybe SqlServer and the IIS Windows Feature), Boxstarter will check for pending reboots before each package. There is lots of information on running Boxstarter at Boxstarter.org.