Menu

My windows development environment in 2016

Every day, we as developers, use a wide range of tools to perform our tasks. Re-installing your machine and getting everything you need is always a bit of a search. So I have created this blog posts to store how I install my development machine.

Installing Windows Powershell version 5 (only on < windows 10)

Download the latest version of Powershell (not required on Windows 10, we use version 5)
Go to the following link Windows Management Framework 5.0 and download Win8.1AndW2K12R2-KB3134758-x64.msu.

Once installed verify your PowerShell version by performing the following command:

This will create an empty file named Microsoft.PowerShell_profile.ps1 in the folder WindowsPowerShell in your My Documents folder.

Open up the file in your default text editor

start $profile

And add the following content to the file:

Write-Host "Hello, world from the default profile"

Restart PowerShell and if everything worked you should be able to see:

It's working :-)

Now create the following folders on your disk:

md Tools
md Repository

They can be placed anywhere on your disk, as long as you remember for now where they are, I placed them on C:\(so everywhere where I use the path C:\Repository or C:\Tools be sure to replace them with your location).

And add a folder inside the WindowsPowerShell folder in your Documents folder with the name Modules. We will store modules here which we will use later on.

Open up your Microsoft.PowerShell_profile.ps1 (type start $profile) file again and replace the Write-Host "Hello, world.. with the following text:

Restart PowerShell. It should now try to load all the scripts it finds in the PowerShellScripts folder and make them available by default. You can test this by performing the following commands:

Add-Path C:\Tools
$env:PATH

This should now display ;C:\Tools at the end of the path string. This is only available during the time the session is open, so when you close PowerShell again it will be lost.

Installing git

Download the latest version of PortableGit from https://github.com/git-for-windows/git/releases and unpack it to the C:\Tools folder. I like to give it the name of the version of git I downloaded (PortableGit-2.10.0-64-bit) so I can easily see what version is installed.

Open up your Microsoft.PowerShell_profile.ps1 (type start $profile) and add the following above the goto repository folder section:

Configure Git

Create a default .gitignore file

Sometimes there are files that you always want to ignore, when checking into git. Also in the case where you did not yet, or forget to add them in the .gitignore file of your repository. We will not create a file to store them and set it up.

You can now edit the file .gitignore that is stored in your user profile folder to add globally ignored files.

Set the default push mode to simple

The default in Git 2.0 is simple.

git config --global push.default simple

Modify the default pager from less to cat

We as windows users are not that used to the less pager (It's that situation where you don't have a clue how to exit this colon thing, see image below), so we can just turn it off and use powershell for paging.
Perform the following command

git config --global core.pager cat

Change the colors used

By default git uses a color that is hard to read on the blue PowerShell color:
We can fix this by running the following commands (this can also be done by editing your .gitconfig file):

Extending the command prompt to show more information.

Posh-Git is a PowerShell extension to show Git information.

We can get it directly from github.com, by performing the following commands:

cd Modules:\
git clone https://github.com/dahlbyk/posh-git.git

We now have a folder called posh-git in our Modules folder.
Open up the Microsoft.PowerShell_profile.ps1 (type start $profile) file from the WindowsPowerShell folder in your Documents folder again and add the following above the goto repository folder section

Restart the PowerShell and goto the Modules folder and into the posh-git folder. The prompt should now display the git branch you are on and when there are changes the amount of files checked out, etc. We also modified the prompt a little bit to remove the PS part of it.

Modify the change directory cd command

In PowerShell the cd command actually is an alias, which can be redirected to another function.
Which comes in handy to make checking out a branch easier, we will wrap the default function with a function that checks if the folder/ directory starts with a :. If that's the case, we perform a git checkout, otherwise we perform the default behavior.

Save the following file in Tools:\PowerShellScripts as Set-Location.ps1 and restart the PowerShell console.

to switch to the develop branch (if it exists, type git branch --list to get a list of branches, type git branch name to create a branch for testing if none exist and git branch -d name to delete it again).

Installing SSH certificate

We will install a SSH certificate so we don't need to provide our username and password on each push to a remote repository (for example GitHub).

Perform the following command in the PowerShell command prompt:

ssh-keygen -t rsa -C "your@email.com"

Press enter to pick the default path to store the ssh key pair. Enter a pass phrase, this phrase is used to allow you to use the certificate and you will need to provide it when starting PowerShell if they SSHAgent isn't running yet.

It will generate a key fingerprint and key's randomart image (both masked with red below) you don't need them for now.

Open up your Microsoft.PowerShell_profile.ps1 (type start $profile) and add the following above the goto repository folder section

Save and restart PowerShell. You should now be able to use your alias, type for example vs to test it.

PowerShell command to start Visual Studio

The alias is nice, but for starting Visual Studio you now still need to type vs solution.sln. We are now going to create an function to open the solution file even quicker. In your PowerShellScripts folder add a file named VisualStudio-Here.ps1 and add the following content: