Certifications / Microsoft

Why You Should Make VS Code Modular

by Team Nuggets
Why You Should Make VS Code Modular picture: A
Follow us
Published on October 21, 2021

Whether you are a casual developer or a budding PowerShell aficionado,         you likely have been using Microsoft's VS Code IDE for some time now. You undoubtedly have your VS Code all pimped out with the extensions and settings that really allow you to be productive. You have colors just right, text just right, and everything is just perfect. Until that eventual dreaded day. Your workstation needs to be replaced.

It could be because of a hardware failure, OS re-image, or just a hardware refresh. Either way, you absolutely are not looking forward to having to re-install and configure VS Code, after it's all said and done with. Luckily for you, there is a way to start from scratch but in a way that makes picking up and moving so much easier in the future. Let's talk about making VS Code portable.

What Does it Mean to be Portable?

Being portable is easy to understand in and of itself, but what exactly does it mean for an application to be portable? Traditional software installations on a Windows PC involves a folder being created in the Program Files or Program Files (x86) folder with all the application's needed files, configurations, and settings. It also means items are written in the registry and the particular user's local profile. We then see it listed under the Programs and Features app of the Control Panel where we can remove or reinstall.

A portable app keeps all those files needed for the application in one source folder. Nothing gets written into the registry and nothing of value is written in the user profile that would be needed if that source folder were to be moved or changed. This makes it easy to move that application to a USB flash drive, external hard drive, or a cloud storage location. This is especially helpful for IT support folks who have a virtual toolbox of applications they need for testing, analyzing, and troubleshooting. All the apps and their settings can be taken on the go to maximize their efficiency.

When to Make VS Code Portable

To recall the beginning of this post, all is well in the world until your workstation is lost, stolen, or crashes. Maybe you have a new laptop coming your way, but thinking about reinstalling everything takes a little bit of that joy away. Because you remember how much effort you put into making things just right for your workflow. It's safe to say that almost every sysadmin has been down this road.

Having a portable setup of VS Code is very beneficial to being able to move your PowerShell IDE to where you need it. In today's increasingly mobile world, this has an ever-increasing ROI. With COVID-19 resulting in large numbers of people working remotely, some sysadmins have had to rethink how they do their work. For instance, you may have the perfect setup on your laptop, but working from home on a slower connection now seems like a pain when running scripts across your corporate VPN. You now find yourself needing to have the same setup on a machine or VM within your corporate datacenter in order to be efficient.

What's nice about making VS Code portable is that it's supported by Microsoft, so they have documentation on how to set it up and maintain it. This isn't a MacGyver hack that sometimes works and sometimes doesn't. Almost all the extra extensions get moved quite easily and allows you to pick up and move your PowerShell hub of expertise to wherever you need it. 

Starting out Portable

It's actually very easy to start out from scratch with making VS Code portable. Head on over to the download page for VS Code and grab the .zip package for your OS/architecture. Unzip the contents of the folder and drop it wherever you would like it to live long-term. Feel free to change the folder name if you would like as well.

One key thing to make this portable is to create a 'Data' folder inside the root of this extracted folder. This will house all the specific settings to your portable version of VS Code. Though not required, you can also have all your VS Code temp data saved in portable mode as well. Just create an 'tmp' folder inside your new Data folder and VS Code will drop all the temp data there. By default, VS Code will utilize the system temp directory.

Once this is done, you're ready to go! Go ahead and install your needed extensions. Because this post focuses on PowerShell in a Windows environment, here are some suggested extensions for making VS Code more PowerShell friendly:

PowerShell. Yes, it's pretty obvious. This extension gives you all the look and feel of an IDE that is designed for PowerShell like IntelliSense for cmdlets, definitions for cmdlets and variables, and syntax highlighting. These, plus more are designed to help you code more efficiently on the fly.

PowerShell Extension Pack. This is an extension that installs various other extensions to help with PowerShell scripting. Most of these are formatting helpers, inline highlighting, error corrections, and many others. A great one-stop extension for PowerShell gurus.

When these extensions, as well as any others, get installed these will live inside the extracted .zip folder you created and moved. It would always be a good idea to make regular backups of this folder so as not to lose your precious PowerShell workshop. You may also look into GitHub integration for VS Code settings as well. There are extensions out there for this.

Migrate to Portable

You may be reading this and thinking to yourself, "Great! I wish I would have known about this sooner." Never fear! You can migrate your traditional install to a portable one with just a few steps.

  1. Download the VS Code .zip distribution for your platform as before

  2. Create the Data folder as above

  3. Copy the user data folder %APPDATA%\Code to Data and rename it to user-data.

  4. Copy the extensions folder %USERPROFILE%\.vscode\extensions to Data. No need to rename it

Once you have migrated, you may want to make a backup of the Data folder as previously pointed out. This will ensure you always have a working copy of the Data folder for when you need to pick up and move again.

The Update Process

Updating the portable version of VS Code is just as simple. Pull down the latest .zip version and extract as in the previous steps. Just copy the Data folder from your working VS Code folder and place it in the same spot of the new version. What is also nice is that when you are prompted to update inside VS Code and you click 'Install Update', it will go out and grab the latest .zip and drop it in your Downloads folder. It will know you are using the portable version and will get the latest portable version to swap to.

You may want to at least keep the previous version folder around in the same spot. You could just append the current folder name with _previous and keep that version around for a bit just in case you run into any quirky issues with your newest version. The more extensions you have the more this may be important. Some extension developers may not be as quick to develop and test their extensions on the same cadence as VS Code updates.

Final Thoughts

As stated before, this will certainly help you to be more agile in terms of setting up shop for using VS Code for your PowerShell development. To most programmers out there, this may have been quite unadventurous but you'll have to let those sysadmins catch up as they get closer and closer to the world of scripting and programming. To the budding PowerShell architect, this is all new and exciting. This may be the natural progression of the trend towards DevOps that has been taking place over recent years.  


By submitting this form you agree to receive marketing emails from CBT Nuggets and that you have read, understood and are able to consent to our privacy policy.

Don't miss out!Get great content
delivered to your inbox.

By submitting this form you agree to receive marketing emails from CBT Nuggets and that you have read, understood and are able to consent to our privacy policy.

Recommended Articles

Get CBT Nuggets IT training news and resources

I have read and understood the privacy policy and am able to consent to it.

© 2024 CBT Nuggets. All rights reserved.Terms | Privacy Policy | Accessibility | Sitemap | 2850 Crescent Avenue, Eugene, OR 97408 | 541-284-5522