Tim Deschryver

How I've set up my new Windows development environment in 2022

@tim_deschryver

In the first week of 2022, I had the joy to receive a new machine from my new employer dotNET lab. In just a few hours I was up and running, let's take a look at my setup as a full-stack .NET and Angular developer.

Getting a new "toy" is always exciting but it's a double feeling because a new development environment involves manual work (remember what software to download, browse to the download page, step-through the install wizard), which is time-consuming. The last time that I configured my machine is a couple of years ago, and I remember that there were lots of sighs involved. This time, a lot in the Windows eco-system has changed. In comparison to the previous time, it was a breeze, making this a fun experience!

Install Software with winget

After the initial installation (and updates), the first step is to make sure that winget is installed, and that it's updated to the latest version. You can do this by going to the Microsoft Store and searching for winget (in the store it's listed as "App Installer").

Installing winget via the Microsoft Store

winget has two important commands winget search to search for software, and winget install to install the software. When using the install command, note that you can pass it the interactive flag to intervene with the installation details by changing the defaults.

Once winget is installed, open a new command prompt and copy-paste the next script. This script installs all of the software that I've used throughout the last month in a single command.

The above script installs the majority, but there are a few programs that need to be installed manually because they aren't available on winget.

Different Node.JS versions with fnm

I use fnm because I need to work within multiple Node.JS versions. With the fnm CLI I'm able to easily install Node.JS version and cycle between them, depending on the project's configuration.

The best part is that fnm automatically uses the correct version. The only requirement is that a .node-version or .nvm file exists in the root directory.

When the specified Node.JS version isn't installed, fnm prompts a install command.

Other helpful commands are install, use, default, and current:

dotNET Tools

Tye has been indispensable in my toolkit for the past year. I was immediately hooked from the first time when I heard about this tool.

Tye makes the development experience a lot smoother when it's required to run more than one application at once. With a single command, all of the development instances (services, applications) are spawned locally (and can be debugged), making it effortless to run a development environment. For example, a .NET Web API and an Angular frontend.

To install Tye, use the dotnet tool install command and install Tye globally.

To run Tye, a configuration file is required, so let's create one. The following example configures two projects (project1 and project2) that have a .NET backend and an Angular frontend.

For the .NET instance, we can simply point to the csproj to run the API. The Angular frontend is served by navigating to the Angular directory and running the serve command.

Now, I can use the tye run command to run one specific project or all projects. By using the watch flag, the application also hot reloads when a change is made to a file.

To run Tye from all directories, specify the tye config path. This allows me to start my development environment from everywhere, without that I have to navigate to the directory where the tye config exists.

Tye also comes with a dashboard to see all the instances that are up and running.

Tye dashboard showing that project 1 is running

Enhancing the Terminal

To make the terminal awesome, I'm using the Windows Terminal together with Oh My Posh.

I compare the Windows Terminal as the default Command Prompt on steroids that has built-in tabs, and it can be tweaked to my preferences. This makes me feel happy, resulting in an increased productivity.

Via the settings of the Windows Terminal, I set the default font and the default profile, which uses PowershellCore. I've also added a few shortcuts to open (ctrl+t) and close (ctrl+w) tabs.

I've set the font to a font family from Nerd Fonts to display the beautiful icons (glyphs) that are used with Oh My Posh. Go to the download page to find your preferred Nerd Font.

To make the terminal cozy and pretty, I'm using Oh My Posh. Oh My Posh also allows me to add key information to my prompt, making it more useful than the normal prompt. For example, my modified Oh My Posh theme (based on the Pure theme) shows the git status, the .NET, and Angular versions. Spoiler, Oh My Posh can do a lot more! For some inspiration, take a look at the default themes.

To also render the icons Visual Studio Code, set the terminal's font of Visual Studio Code (via terminal.integrated.fontFamily) to the same font from the Windows Terminal config. By doing this, you'll get the same experience no matter where you are.

For example, the experience within an Angular repository looks as follows.

The terminal shows the path, the current branch, and the installed Angular version

For more details and options about the terminal, I highly recommend My Ultimate PowerShell prompt with Oh My Posh and the Windows Terminal by Scott Hanselman, or the recorded version How to make the ultimate Terminal Prompt on Windows 11.

Powershell Profile

Here's where things get interesting, and this part often raises eyebrows while I'm pair programming.

Because the default terminal uses Powershell a lot of tasks can be scripted. To reduce my keystrokes, I like to create aliases and shortcuts to quickly get done what I want to do. The best part is that these tasks are at my disposal when I'm in the terminal.

The Powershell scripts are created in a Powershell profile, accessible via the $PROFILE variable. To create the profile, either manually create the file at "C:\Users\USER\Documents\PowerShell\Microsoft.PowerShell_profile.ps1", or use a command to create and open the file, e.g. code-insiders $PROFILE (if you're using the normal Visual Studio Code, use code $PROFILE).

My profile, which can be found below, creates a couple of functions and aliases to:

Shows a history of npm run commands when I type "npm run", I can also browse through this list

Git Defaults

The following script sets a git identity and configures git to behave the way that I want.

To sign commits I've followed the blogpost A guide to securing git commits from tricking you on Windows by Ankur Sheel.

Visual Studio Code Plugins and Settings

If you know me, you already know that I like to customize my Visual Studio Code setup. The following scripts don't include (color or icon) themes because I like to frequently rotate between them, depending on my mood.

However, the next script installs all of the mandatory extensions to be productive. Because I'm using the Insiders version of Visual Studio Code, I'm using code-insiders instead of code.

For the completion, here's my entire settings.json file.

Visual Studio Exceptions Settings

A setting that has saved me a lot of time is the "Common Language Runtime Exceptions" setting. By default, the setting is partially enabled but I always enable it because it immediately points me to the source of the exception rather than I have to debug the entire stack to find the exception. When the setting is enabled, the debugger breaks on all exceptions and it navigates to the source. This makes it straightforward to find and fix bugs.

To enable the setting, use the ctrl+alt+e shortcut and tick the "Common Language Runtime Exceptions" checkbox.

Enable "Common Language Runtime Exceptions"

File Explorer Options

As a software developer, seeing hidden files and more importantly, the file extension is a must. Via the "File Explorer Options" window these two options can be enabled.

Modified file exploring options

Allow Insecure Localhost

To run an Angular application on HTTPS locally you can create a self-signed certificate, but I find it easier to allow invalid certificates on localhost. This is a flag that can be enabled via the browser.

Enable invalid certifactes for localhost development

Conclusion

From my recent experience, it's painless and swift to set up a new Windows machine anno 2022. To make our daily work more enjoyable, the Terminal and the IDE are configured to our needs and preferences. I've created PowerShell profile to script frequent tasks, making them easy and fast to run, often with only a few keystrokes. While these seem small, it definitely is a productivity boost.

The last step is to clone your Git repository and start working.

Enjoy your new device!


I appreciate it if you would support me if have you enjoyed this post and found it useful, thank you in advance.

Buy Me a Coffee at ko-fi.com PayPal logo
Support the blog Share on Twitter Discuss on Twitter Edit on GitHub