Posh-git installation

Posh-git is a set of PowerShell scripts which provide Git integration. This post describes how to install posh-git on Windows 10 Enterprise without any proxy.

The easiest way to install posh-git is using Chocolatey, which is a Machine Package Manager – tool like apt-get – but for Windows. Chocolatey can be installed based on description on project page https://chocolatey.org/ 

So in order to install Chocolatey open Command Prompt (cmd.exe) in administrative mode, paste and run the following command:

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString(‚https://chocolatey.org/install.ps1’))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

After installation is finished screen should look like this and after seeing this message restart Command Prompt in order to be able to use choco command:

chocolatey installation done - warning

After restart run ‘choco install poshgit’ command.

During installation confirm all the questions and you should see output as below:

poshgit installation

3rd install

4th screen

During installation on Windows 10 PowerShell acted like it was freezed so don’t hesitate to use enter key in order to see the progress.

When installation is finished run PowerShell as an Administrator. After loading prompt you can see error as in the picture below:

5th powershell error

In order to get rid of this message (and load correctly PowerShell profile) you must change execution policy in PS, e.g. using cmdlet Set-Executionpolicy –ExecutionPolicy Unrestricted

After PowerShell restart this error should disappear. However there is one more step to complete for posh-git to work correctly. As for day of this post creation there’s known error in Microsoft.PowerShell_profile.ps1 which causes posh-git not fully functional, so this file content should be updated. Microsoft.PowerShell_profile.ps1 file is placed in C:\Users\your_user_name\Documents\WindowsPowerShell folder.

Replace file content with the following:

# Load posh-git example profile
. ‚C:\tools\poshgit\dahlbyk-posh-git-fadc4dd\profile.example.ps1’

Rename-Item Function:\Prompt PoshGitPrompt -Force

function Prompt() {if(Test-Path Function:\PrePoshGitPrompt){++$global:poshScope; New-Item function:\script:Write-host -value "param([object] `$object, `$backgroundColor, `$foregroundColor, [switch] `$nonewline) " -Force | Out-Null;$private:p = PrePoshGitPrompt; if(–$global:poshScope -eq 0) {Remove-Item function:\Write-Host -Force}}PoshGitPrompt}

Save file and then restart PowerShell – happy work with Git using PowerShell.

Self-development – Microsoft Virtual Academy

I would like to recommend to everyone a great source of technical training, which is Microsoft Virtual Academy (MVA). You can find link to it in the right sidebar of my blog or go straight to http://www.microsoftvirtualacademy.com

MVA is a great place to learn at own pace. Many of trainings are published then on Channel9 (http://channel9.msdn.com), but some of them aren’t (and vice versa). There is a huge number of trainings available now and everyday it’s increasing. Many of them are also recordings from live events, so if you can’t participate, you can always watch them whenever you want.

As already mentioned before, many trainings are available on Channel9, however there’s something special what makes learning using MVA different and attractive. In order to finish given course you need to finish all the modules in it and each module has a ‚prove your knowledge’ part in which some questions needs to be answered based on watched material. Having such a perspective when watching videos, requires more focus during them in order to complete given quiz.

If you’re a fan of gamification then you can probably also find scores and achievements functionality quite relevant. That’s not in my case, however what I like the most (apart from great trainings) is a video platform which is able to remember where you left off. Add to this possibility to personalize your training plan and we’re good to go (no more hundreds and thousands of bookmarks in the browser).

One disadvantage I’ve noticed so far is the search. Really I can’t find anything using the search box, in fact it’s sometimes easier for me to search a training, which I know name (or part of it), using google (btw the same is true for Channel9 search – at least in my opinion).

Ok, that’s it for now, going back to my training plan on MVA 🙂

ASP.NET vNext on Ubuntu Linux

Disclaimer: Please note that this description is made based on taken notes during installation and is a subject to change after additional verification.

Described installation has been made on Ubuntu 14.04.

In first step let’s update packages information using:

sudo apt-cache update

Next step is installation of Mono prerequisites:

sudo apt-get install git autoconf libtool automake build-essential mono-devel gettext libuv0.10

Then clone Mono repository from GitHub to selected folder, install it and verify instalation:

mkdir mono
cd mono
git clone

Change directory in order to execute autogen.sh script

./autogen.sh –prefix=/usr/local && make && sudo make install

And check Mono version using:

mono –version

By default this version of Ubuntu does not have installed Curl so we need to install it:

sudo apt-get install curl

Install KVM and perform upgrade:

curl -sSL https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh && source ~/.kre/kvm/kvm.sh

kvm upgrade

You can clone now official GitHub repository for ASP.NET vNext using:

git clone https://github.com/aspnet/home

However in order to restore required nuget packages additional certificates installation is required:

sudo $CERTMGR -ssl -m
sudo $CERTMGR -ssl -m https://nugetgallery.blob.core.windows.net
sudo $CERTMGR -ssl -m https://nuget.org
mozroots –import –sync

Now you can call in selected project folder following command:

kpm restore

Everything should work for console application, however in order run e.g. MVC project additional configuration is needed (installation of Kestrel from source code):

sudo apt-get -qqy install \
autoconf \
automake \
build-essential \

In separate folder clone libuv repository:

git clone https://github.com/libuv/libuv

Install and configure it:

./autogen.sh && ./configure && sudo make install
sudo ldconfig

Now for MVC project after calling “kpm restore” you can now run it using:

k kestrel

angular.js npm run protractor Ubuntu 14.04 error

When going through angular.js tutorial I’ve faced issue when running end-to-end tests with protractor.

npm run protractor

command didn’t work, even after running as advised following commands:

npm install

npm run update-webdriver

In order to fix this issue I’ve installed chromium-webbrowser and also removed protractor entry in package.json file. After that I’ve run:

npm install protractor –save-dev

and next time after running protractor everything worked as expected

Windows Task Scheduler and PowerShell scripts

Just a quick memo:

When you run PowerShell script using Task Scheduler remember to place „exit 4” at the end of script (without quotation marks). This code means that script has run successfully.

Sublime Text 2 save session on Ubuntu problem

I’ve had never before problems when using Sublime Text 2 (ST2) on my Windows 7 machine. Especially concerning my favorite feature which automatically opens files opened during last session. However I’ve faced such a problem on Ubuntu. Despite hot_exit and remember_open_files properties set to true, no files from last session had been opened. Some people even raised this as a bug (googled for it).

I’ve noticed strange behavior that when trying to change settings (some experiments) dialog box with permissions denied information appeared. However running ST2 using sudo command allowed me to save changes in settings files. So it appeared to me as permissions issue. If I can’t save settings as standard user then maybe session data can’t be saved in similar way. I’ve checked permissions for files in ~/.config/sublime-text-2/Settings and owner of all files had been set to root. I’ve called command:

sudo chown your_user_name Session.sublime_session

…and it works now as designed. After closing editor and opening it once again all files opened during last session are restored.

TFS2010 – find changeset for label – quick tip

Management of labels in TFS 2010 using Visual Studio 2010 is not especially user friendly. Recently I’ve faced a situation when I had to find for which changeset label has been created. The simplest solution appeared to be usage of developer command prompt and invoking command in local solution workspace:

tf history . /stopafter:1 /noprompt /r /version:LNameOfMyLabel

Please note capital L after version parameter with colon. This L is used to mark that search should be performed for label with specified name after it.