In an increasingly agile world of programming and DevOps, not only do the applications and tools you code need to be modular, you may find yourself and the programs needing to be modular as well.
Whether you are a casual developer or a budding programming enthusiast, you likely have been using Microsoft’s VS Code IDE for some time now. You may have custom colors set, text formatting just right, and everything is set just to your liking. You undoubtedly have your VS Code all decked out with the extensions and settings that allow you to be productive. Until that eventual dreaded day. Your workstation needs replaced! It could be a hardware failure, OS re-image, or just a hardware refresh. Either way, you do not look forward to having to re-install and reconfigure VS Code. 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, with the focus being on using VS Code to mainly develop with PowerShell on a Windows PC.
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 involve a folder 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 re-install from there.
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 necessary if that source folder were to be moved or changed. This architecture makes it easy to move that application to a USB flash drive, external hard drive, or a cloud storage location like DropBox, OneDrive, or Google Drive. All the apps and their settings can be taken on the go to maximize their efficiency. Having this configured is especially helpful for IT support folks with a digital toolbox of applications they need for testing, analyzing, and troubleshooting.
Why Would You Want to Make VS Code Portable?
If you recall the beginning of this post, all is well in the world until your workstation is lost, stolen, or crashes. It’s safe to say that almost every SysAdmin has been down this road at least once. Maybe you have a new laptop coming to you, but thinking about re-installing 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.
Having a portable setup of VS Code is very beneficial in order to move your PowerShell IDE to where you need it. In today’s increasingly mobile world, where we work from could potentially have an ever-increasing ROI. With so many companies allowing staff to work 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 to be efficient.
What’s nice about making VS Code portable is that Microsoft supports it, so they have documentation on setting it up and maintaining it. This isn’t some quirky MacGyver hack that sometimes works and sometimes doesn’t when the stars don’t align. Almost all the extra extensions and everything get moved quite easily and allow 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 making VS Code portable. Head on over to the download page for VS Code and grab the ZIP package for your OS/architecture. Portable mode is supported only on the ZIP download for Windows, the TAR.GZ download for Linux, as well as the regular Application download for macOS. 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. For this example, I have extracted the ZIP file to a USB drive and created the Data folder.
The Data folder 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 a ‘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, let’s look at one fundamental extension you would want to install.
The official PowerShell VS Code 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.
When this extension, as well as any others, gets installed these will live inside the Data folder created inside 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.
In this example, I am able to take this USB drive to another Windows machine and open up VS Code with all my settings and extensions. There may be some other tweaks you may want to change within the settings of VS Code to make moving around even more seamless, like the default location of the integrated terminal opens up at. This, by default, opens the PS prompt in the current user’s folder. You could hard code this location to a more generic folder, as profile names will change from station to station.
Depending on the structure and cloud storage provider you use, you could also set this up in a synced folder so as to have these settings set for a number of machines you frequently use.
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 standard install to a portable one with just a few steps.
- Download the VS Code ZIP distribution for your platform as before.
- Create the Data folder as explained previously.
- Copy the user data folder %APPDATA%Code to a folder named user-data inside the created Data folder.
- Copy the extensions folder %USERPROFILE%.vscodeextensions inside the created Data folder.
These steps, plus the steps for other OS platforms, can be found on the VS Code Portable Mode documentation. Once you have migrated, you may want to back up the Data folder, as previously pointed out. This will ensure you always have a working copy of the Data folder when you need to pick up and move again.
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 as the new version. It is also nice that when prompted to update inside VS Code, 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.
You may want to keep the previous version folder around in the same spot. You could append the current folder name with _previous and keep that version around for a bit in case you run into any quirky issues with the 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.
To the budding PowerShell architect, this is all new and exciting. As stated before, this will undoubtedly help you be more agile in setting up shop for using VS Code for your PowerShell development. To most programmers out there, this may have been relatively unadventurous, but you’ll have to let those SysAdmins catch up as they get closer and closer to the world of scripting and programming. This also may be the natural progression of the trend towards DevOps that has been taking place over recent years.
- › Microsoft Is Transforming Bing Into an AI Search Engine
- › The AirPods Pro Has New Competition: The OnePlus Buds Pro 2
- › The Best Earbuds for iPhone Fans Just Hit Their Lowest Price
- › How to Block or Unblock Someone on TikTok
- › The OnePlus 11 Is Here, but With a Rough Start
- › Microsoft Edge Is Getting AI Chat and a New Look on Windows