Tuesday, September 22, 2020

How to automate the setup of Win 10 development machine by scripting?

Problem

As developers, many of us get a new upgraded machine every 3 years. Sometimes we may get earlier due to project change, machine complaints, or change of company. Every time we get a new machine we are not only getting a new machine but a boring task as well. 
Some software would already be present in the machine, some may not. Also, the versions may be different than what we need.

More than the software, there are some settings also we would like to be in or machine. eg: Mouse pointer speed, showing the extension of known files. etc...

Provided we have the admin privileges in the dev box, it is very difficult to convince managers that we need 6-8 hours to set up a new machine. Forget about developers who don't have admin privilege in their machines and raising tickets to get a change. They really should consider updating their resume.  

Below are some settings and software I prefer to be in my dev box 

Environment

These depend on person to person.
  • Show all files, extensions, protected OS files, the full path in the title bar
  • Increase the mouse speed
  • Disable sleep on AC Power
  • Remove preinstalled UWP apps- Windows maps, Microsoft Tips

Software inventory

Again this list also changes per developer depends on what technology they are working.
  • Git
  • Chrome
  • PowerShell 7
  • Node.JS
  • VS 2019
  • Java
  • GraphViz
  • Fiddler
  • Notepad++
  • VS Code
  • VS Code Extensions
  • LogParser 2.2
  • PowerBI desktop
  • Firefox
  • Remote Desktop Manager Free
  • Postman
  • Telerik Just decompile
  • UiPath studio
  • VLC Player
  • OBS Studio

Approaches

Below are some approaches other than the standard answer dockerize your environment. Docker helps to standardize the application runtime. Oh yes, we can install VSCode in docker and access remotely. Another option is to use GitHub Codespaces when they become available. The containerized option may not work for all the developers. Especially if they want to work on legacy technologies. Hence considering the below options

Developer machine image+preinstalled tools

This is what the first idea comes to us especially if we are from old age. This was a revolution one time. But nowadays people don't feel this as modern. Why this is not a good idea?
  • No idea what will be in the image.
  • No version control.
  • Every update has to go via the infrastructure team or someone who reimage machines
  • Has to reimage the existing machine when a new tool is introduced also after a version upgrade.

Winget+PowerShell

Microsoft recently introduced a new package manager for Windows. That space was already occupied by other package managers such as Chocolatey. WinGet has a public repository of package manifests. It is really in its infancy. So better wait for how it evolves than just jumping on it.

Obviously, PowerShell is required to change configurations that the package manager don't provide such as changing power options,

Choco+PowerShell

Choco is the short form for Chocolatey mentioned above. This package manager is there for some time. No idea why Microsoft didn't acquire them and set as the default package manager for Windows. Along with Boxstarter, Chocolatey+PowerShell is a good team.

Ansible+PowerShell

Ansible is an agentless configuration management platform to simplify deployment. It is mainly on Linux but supports Windows as well. As per their Windows strategy, it uses PowerShell to get things executed. Also, it can integrate with Chocolatey to install packages. Even it can execute any custom PowerShell scripts. More than all these it supports YAML which feels more declarative and modern.

Solution

Choco+PowerShell with Boxstarter seems the easiest approach to start with. But definitely, Ansible is promising. 
The next decision we need to take is whether we should fork an existing GitHub repo or start our own. I reviewed some repositories but finally decided to start my own by taking ideas from them. The rationale is that most of the repositories are personal. Moreover, every developer will have their own preferences.
 
Below is my repository. It currently has Choco+PowerShell approach to install and set up a dev environment on a fresh Windows machine. It assumes the required rights on the machine.


It starts with installing Chocolatey itself. The Boxstarter provides a web-based install by a click of URL.

Since the list of software evolves over a period of time, I am not listing what are the capabilities added in this post. Please refer the repo

No comments: