Best way to setup dev environment on Windows

Sasi
4 min readOct 13, 2023

Every organisation trying to boost the Employee efforts in core area instead of spending time on environment issues.

When organisation onboarding new employees, most of the time the process might lack efficiency and the new Software Developer or Engineer may not receive the proper experience.

Setting up the development system with require software is most important one to start the work in that organisation. This process may vary based on the company’s software policies, system type(physical or virtual machine) and operating system.

Windows is most widely using operating system for its user friendly interface.

This article provides insights on the best way to setup and handle the softwares on Windows machine in the organisation.

Software Installation Challenges

  • Manual installation process
  • Need to cross check the company policies every time
  • Need to figure out the approved plugins for each IDE

Automate the setup process

To overcome the above challenges we need the package manager which can offer flexibility to manage the software in Windows system.

Chocolatey is the famous command line package manager which is using PowerShell script for software installation.

Chocolatey Package Lifecycle

The above diagram explain the Chocolatey package lifecycle in high level. Organisation keeps the software packages in private artifactory for secure access. Once the security and vulnerability scan completed, it can be released for Employee access.

So, we need to configure our code in the way that it can download the latest version and build the package (.nupkg) for the Chocolatey.

Preparation of Chocolatey Package

PowerShell helps to prepare the Chocolatey package for install/update/delete. With the basic knowledge of PowerShell scripting we can achieve this.

Prerequisites

  • Windows system with latest PowerShell
  • Chocolatey should be installed in that system with core package
  • Compressed version(.zip) of installation software package

Installation Script

First we need the Chocolatey installation script file for install configuration. Lets look into the below sample file.

Chocolatey Installation Script

First we need to declare stop action for ‘ErrorActionPreference’ . Then add the variables for version, operating system, architecture and type.

Once we have all the values, can merge to require path using predefined PowerShell cmdlet like ‘Join-Path’. Also fetch the system values from environment variable using $env.

Then, club together all the package arguments to pass as single argument in ‘Install-ChocolateyZipPackage’ function.

Finally we can configure for system path to recognize the installation software in the command line.

Uninstallation Script

We need to create Chocolatey uninstall script, similar to the installation.

Chocolatey Uninstallation Script

Here we need to remove the installed package using ‘Remove-Item’ function.

Package Specification

Chocolatey uses the same infrastructure as NuGet. So, we need to add the package specifications in Nuspec file which accepts the XML format.

This file contains the package related information like author, owner, version .. etc,.

Also we can mention the dependency package details in <dependencies> tag which make sure that specific package is installed in the system.

Package Build

To build the package we need to place the PowerShell scripts under tools directory as mentioned in the specification.

Also, place the source and Nuspec file under src as shown above. Then execute the below command in src folder to generate the Nupkg.

choco pack

Once the Nupkg(.nupkg) generated successfully, we can upload it to the Chocolatey artifactory location. So that it will be available for all the employees in the organisation.

Build Automation

We can automate the entire build process using gradle or python or anyother build tool depends on our convenient. It can handle the below steps.

  • Download the latest source package from artifactory
  • Update the specification details in the Nuspec file
  • Generate the Nupkg
  • Upload it into the Chocolatey artifactory

We can setup the same thing in CI/CD pipeline too. So that the authorised person can execute it whenever is required.

Advantages of Chocolatey Package

  • Open source tool
  • Giving flexibility to modify the configuration based on company policies
  • Developer need not to worry about security check
  • No need to cross check the approved packages in the organisation
  • Can make single command to install all the require package for new system.

This way we can group the tools based on the roles like Developer, Tester, DevOps Engineer ..etc, and prepare the single script file(.bat) and share it across the organisation. It reduce the unnecessary setup work and improve the employee productivity.

References

--

--