Downloading Visual Studio like a boss, including Visual Studio 2017

SubPointSupport
Mar 20 · 5 min read

Downloading and managing installation media is not fun. Whether it is development, test or lab environment, dozens of ISO images, patches, updates and language packs have to be downloaded prior to setting up Windows, SQL or SharePoint environment. Sometimes, it might be up to fifty files to move around!

Visual Studio is one of the tools to be installed for development, test or lab environments. Versions prior 2017 come as ISO images, so they are easy to work with. Visual Studio 2017 works differently: it comes with a special bootstrapper to download needed packages and create offline installations, so additional work to automate this process is required.

This post shows how to create an offline installation for Visual Studio 2017 with pure PowerShell script, and how we automated it with ready-to-use InvokeUplift PowerShell module so you can use it straight away!


Dealing with Visual Studio prior to 2017

Versions prior 2017 come as ISO images. Downloading experience, in this case, is as easy as download a remote file. The only thing you should care about is URLs for various Visual Studio versions. Most of them can be found on the GitHub but here are quick links to get started:

Downloading experience is pretty straightforward:

While the script looks simple, there are several things to be aware of:

  • wget and curl are aliases for invoke-webrequest, hence scrip specifically adds .exe extension
  • -UseBasicParsing option makes it work under PS < 6 and freshly configured systems
  • Invoke-WebRequest PS < 6 might fail on large files. PowerShell 6 performs much better so pwsh usage might be recommended
  • pwsh works super-cool under Windows 2008 -> 2016, MacOS and Linux!
  • None of the above methods provides checksum validation out of the box, additional work to validate checksum is required

As you can see, there are several pitfalls already with just a simple file download. We build a reusable InvokeUplift PowerShell module to hide this complexity. Here is how you can download all pre-2017 Visual Studio ISO literally with one line:

InvokeUplift comes with a command line interface, JSON driven configurations, built-in checksum validation and a few more nice features. Being written in PowerShell 6, it works on Windows and MacOS platforms.

Dealing with Visual Studio 2017

Visual Studio 2017 works differently: it comes with a special bootstrapper to download needed packages and create offline installations if needed.

Depending on the target workload, such as .NET development, Azure, NodeJS and others, the bootstrapper download needed modules. Average install size might take between 5–9 Gb, and the full install is around 35 Gb! Therefore, for local scenarios, creating offline installation might make sense.

Downloading experience With Visual Studio 2017 is less straightforward but still can be scripted. Two steps are involved:

Here is a 50 lines long pure PowerShell script implementation:

The script pre-downloads bootstrapper, and then executes it with the right parameters. Once done, it starts Visual Studio 2017 layout creation into target folder:

A few points here:

  • Consider--quiet option for fully unattended install
  • Consider packing the layout folder into a zip archive (easier to move around)

Now, here is how Visual Studio 2017 can be downloaded with InvokeUplift PowerShell module:

That’s it! One line and all the heavy lifting of downloading and preparing the layout is done for you.

By default, the uplift module downloads Visual Studio with the most common development components. It should cover most of the development scenarios, but we can always craft a custom JSON definition for different Visual Studio layouts.

The InvokeUplift module uses a naming convention while organising downloaded files. Local file repository always looks as follows:

In the case of Visual Studio 2017, the downloaded structure contains both raw layout folder with thousands of files and a zip package under /latest folder. ZIP package is easier to move around, for example into Azure/AWS cloud, to a virtual machine, Vagrant/Packer boxes and other shares.

Initially, files are downloaded into the/download-staging folder. If checksum passes, then the file is moved into the /latest folder. Such downloading workflow prevents badly downloaded files corrupting the current “latest”. Only checksum validated files can go into the/latest folder.

A few notable parameters while downloading files: -debug, -force and -repository, and the full list of them and other resources can be found our previous post — Easy installation media download for busy SharePoint engineers.

Why use this at all, and some ideas

Initially, we struggled with file downloading while building golden images for our development and integration environments. Downloading and managing installation media was a manual, boring and error-prone process.

Nowadays, invoke-uplift is an important part of several other projects — Packer images and Vagrant boxes for SharePoint engineers. Every single bit is under CI/CD pipeline, complexity is covered and exposed via single line command, we almost forgot how to download things via browser, and so should you! Moreover, invoke-uplift works under MacOS streamlining Windows/Macbook experience.

Full details on this PowerShell module can be found in the previous post:

What else can you do?

Once you built up your local file repository, here are a few things you can do:

  • Easy expose via shared folders, nodejs http-server , or any web server
  • Sync with Azure/Amazon Cloud storage
  • Build a CI/CD pipeline to pre-build your Azure/Amazon Cloud storage
  • Run local http-server and easily share files with Packer/Vagrant builds

If you find this useful, drop us a line or give feedback on the GitHub, feel free to share feedback and improvements in the comments, follow us here or on Twitter and feel free to share this post too.

SubPointSolutions

Easy SharePoint automation for developers and engineers.

SubPointSupport

Written by

Easy SharePoint automation for developers and engineers. Provision SharePoint artifacts and deliver SharePoint infrastructure with confidence, sanity and joy.

SubPointSolutions

Easy SharePoint automation for developers and engineers.