Installing individual components to Visual Studio 2019 from the command-line

June 7, 2021 – Samuli Seppänen

I've been doing lots of Windows automation recently. My goal has been to be able to reproducibly create a Windows Server 2019-based Buildbot workers, first in a Vagrant environment, then later in AWS EC2 using pre-built images created with Packer. This task requires installing Visual Studio 2019 build tools automatically and fetching the project's dependencies with vcpkg automatically. It is possible to install Visual Studio 2019 with Chocolatey quite easily, but what if you need to install additional components to Visual Studio without using the Visual Studio installer GUI? Looking around did not quickly reveal any de facto instructions on how to do it, so this article aims to fill that gap.

First you need to locate your Visual Studio installer. In my case it was located in C:\Program Files (x86)\Microsoft Visual Studio\Installer, but yours may be in a different location. To find out where, launch an administrative Powershell prompt and do this:

PS C:\something> cd C:\
PS C:\> Get-Childitem -recurse -filter "vs_*.exe"
--- snip ----
Directory: C:\Program Files (x86)\Microsoft Visual Studio\Installer
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         6/7/2021   9:41 AM         103304 vs_installer.exe
-a----         6/7/2021   9:41 AM          31160 vs_installer.windows.exe
-a----         6/7/2021   9:41 AM         103304 vs_installershell.exe
-a----         6/7/2021   9:41 AM         150936 vs_layout.exe
--- snip ---

The name of the executable varies between Visual Studio versions, but here it is called vs_installer.exe. To get an understanding of how the installer works see its official documentation.

The key to installing new components is to use modify with the --add parameter. The --add parameter expects either a workload ID or component ID. The Visual Studio workload and component IDs contains links to all Visual Studio components per Visual Studio variant. Armed with all this information you're ready to craft a command-line:

PS C:\Program Files (x86)\Microsoft Visual Studio\Installer> .\vs_installer.exe modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Buildtools" --add Microsoft.VisualStudio.Component.Azure.AuthoringTools --downloadThenInstall --quiet

Explanation of the parameters:

  • modify means we're modifying an existing installation
  • --installPath must point to your Visual Studio installation. It must not end with a backslash or vs_installer.exe will choke.
  • --add parameter determines what to install - it must be a valid component ID (see above)
  • --downloadThenInstall does what is says on the tin
  • --quiet ensures that we don't get any GUI crap popping up (use --passive if you want to see the GUI)

The interesting thing is that without either --quiet or --passive the Visual Studio installer will only select the components you added, not actually install them.

Want to talk to an expert?

If you want to reach us, just send us a message or book a free call!
Categories

Tags

#aad #Access #acl #alertmanager #ansible #ansible module development #Apache #API #augeas #authentication #authorization #automation #automatization #aws #azure #backup #bash #bitbucket #buildbot #cache #centos #cloud #cloud-init #cloudflare #cloudfront #cluster #connectionsJpa #control repo #custom fact #database #debian #devops #digital sovereignty #DNS #docker #domain mode #duplo #ejabberd #email #encryption #erb #europe #eyaml #fabric #facter #facts #fargate #fedora #file #finnish #foreman #freeipa #git #github #gitlab #gnome #google #grafana #hammer #hiera #IAM #import #infinispan #Infrastructure as Code #ipmi #irc #jboss #jdk #jenkins #JMESPath #kanban #keycloak #librarian-puppet #librenms #linkedin #Linux #Location #loop #marketing #mautic #Mellon #mfa #monitoring #mysql #nagios #network-manager #oauth #oauth2 #office365 #open source #openvpn #oxygen #packer #paranormal #pdk #people #php #pkcs7 #pomodoro #Powershell #preseed #presentation #profiles #prometheus #provisioning #puppet #puppet-bolt #puppet-litmus #puppetboard #puppetdb #Puppetfile #puppetserver #puppet types and providers #pxeboot #qemu #quality #r10k #recruitment #redirect #Restrict #Reverse Proxy #roles #rspec #ruby #SAML #sem #shell #showsql #snmp #snmpd #software developement #spam #ssh #sso #standardization #systemd #systemd-resolved #teams #terraform #ubuntu #user-data #vagrant #vanity awards #variable #vim #virtualbox #visualstudio #webdevelopment #wildfly #Windows #wireguard #wordpress #workflow #x11 #xmpp #zimbra
We are
 Puppeteers
menucross-circle