Monday, 19 December 2016
Thursday, 27 October 2016
Window Server 2016 and Windows Containers
1. Windows 2016 Virtual Machine
2. Install Containers Feature
Restart-Computer -ForceOnce the machine is restarted, continue with following
3. Install Docker
Invoke-WebRequest "https://download.docker.com/components/engine/windows-server/cs-1.12/docker.zip" -OutFile "$env:TEMP\docker.zip" -UseBasicParsingYou will have two executable files in the extracted directory as shown
Alternate Installation Option
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Once installed, verify that docker is running fine your machine by type in the following
docker run microsoft/sample-dotnet
You should see a message of the like "Welcome to .Net Core!" on your console window. This means that your docker instance is working fine.
4. Pulling microsoft/windowservercore image
So, this is where I got stuck a bit. I was trying to use microsoft/nanoserver, which is a fraction of a size of full windows image and support .Net Core. In the end, I found out that running vso agent on server on nano server is not supported yet.
So, I pulled the full server core image. You can do it by running
docker pull microsoft/windowsservercore
The image is about 8GB and takes some time to download. Once pull, run the image by typing in
docker run microsoft/windowsservercore
At this stage, we are on a windows docker container running Windows 10. I checked in by typing and got the following version
Major Minor Build Revision
----- ----- ----- --------
10 0 14393 0
5. Running VSO Agent
Now that we have a running container, the steps to run VSO Agent is as simple as running it on any Windows 10 machine.
The only complication is the lack of GUI, so I used powershell to download zip file and extract it as follows
Invoke-WebRequest https://github.com/Microsoft/vsts-agent/releases/download/v2.108.0/vsts-agent-win7-x64-2.108.0.zip -outfile vsts-agent-win7-x64-2.108.0.zip
Expand-Archive -Path .\vsts-agent-win7-x64-2.108.0.zip -DestinationPath C:\vsts-agent
You will see the usual vsts agent's files in the destination directory. Simply type in .\config.cmd and follow instructions.
Sunday, 2 October 2016
Containers are brilliant in that they provide a rather lightweight mechanism of setting up desired software in your build agent without installing it on host machine or in a virtual machine. In this post, I will explain setting up a Docker container on a Windows 10 machine, install all the desired software for build agent and running a build to compile an ASP.net core application on it.
This post is split into following areas
- Setting up Docker on a Windows 10 machine
- Create a Docker image to run Build Agent.
- Configure and run a Build Agent on Docker.
- Run a Build on the newly setup Build Agent.
Set up a Docker container on a Windows 10 machine
docker run -it hello-world
Create a Docker image to run Build Agent
docker run Ubuntu:16.04.It would look for the instance locally and if it's not found download it from Docker hub. Once the command is complete, the Docker Ubuntu 16.04 image will appear in your “docker images” command
We now install Node.js, npm and vso agent onto the image and store it as another image. To do that the first step is to run the Ubuntu:16.04 image as a container. To do that, run the following command.
docker run -t -i Ubuntu:16.04You will now be on command prompt of root. To run the desire software, run the following commands one after another
apt-get updateMy Ubuntu 16.04 instance didn't have https protocol installed, so installed it by running
apt-get install npm nodejs
apt-get install nodejs-legacy
npm install vsoagent-installer –g
apt-get install apt-transport--httpsWe will also need to install git on it
apt-get install git
sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
apt-get install dotnet-dev-1.0.0-preview2-003131At this stage, the container contains all the software that you need to run a vso build agent.
Configure and run Build Agent
The only thing left to do now is to configure the build agent. The agent installer allows us to easily create multiple agents on a single server. Each agent will run inside its own folder. We create a folder called MyBuildAgent1 and uses it to run the agent. To do this run the following commands
mkdir MyBuildAgent1All commands so far has been run using the root user. We don't want to run the build agent to run as root, so will create a user called buildagentuser and switch to it to use it. Below are the command that you need to run.
chown -R buildagentuser /MyBuildAgent1
The build agent is almost ready to run. At this stage we want to commit this container to save the image. This way we can use it again.
Step out of Docker container by pressing CTRL+P followed by CTRL+Q. You will be back to command prompt. Now type in "docker ps" to view the list of containers running. You will see a response like following
Here, the ubuntu:16.04 running container has the Id "aea7e12541d5". We will commit this container to create a new image. To do this, type in the following on your command prompt
docker commit -a "Hamid Shahid" -m "Basic vso .net core build agent" aea7e12541d5 basicvsogent:v1If you are following instructions, please use your container id. You can verify it by running "docker images". You will see the new image in the list of images
Since, we just "stepped out" of Docker container we were working now, we will now reattach it and run the build agent. To do this type in
docker attach aea7e12541d5Now start the build agent by running
node agent/vsoagentYou will be prompted about your VSO url and the credentials to connect to. I used the following options in the prompt
The user you specify must have the service "Service Account" role in the agent pool you specified. In my case, I had added them to the VSO group "Agent Pool 1 Service Account Users".
Now that my build agent is now running, I will create now create a simple build definition to run the build. We had already created a simple .Net core Asp.net application.
Run a build on the new build agent
This is so awesome. Now that we have the Docker image captured as well, we can start other build agents and distribute our build load across containers. This is far more efficient than running virtual machines as build agents.
Friday, 27 May 2016
The installation proved to be a bit trickier than I thought, so sharing my experience so as to help other out. The flavour of Linux I used was Ubuntu 16.04 LTS.
At the time of writing this post, the instructions present on Microsoft .Net Core website are for Ubuntu 14.04. Tried to follow the steps described on the website. However, execute dotnet failed with the following error on my machine
Failed to initialize CoreCLR, HRESULT: 0x80131500
So tried to proceed with some other steps. In general, installing .Net on Ubuntu require the following steps
1) Add .net repo to trusty sources list
2) Add key for the newly added trusted source
3) Install dotnet
To do the above, open up a terminal on your Ubuntu machine.
To add repo, run the following command
sudo sh -c 'echo "deb [arch=amd64] http://apt-mo.trafficmanager.net/repos/dotnet/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'To add the key, run the following command
sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893Once, the above done, it's bes to update everything by running
sudo apt-get updateNow that everything is done, .Net can be installed by running
sudo apt-get install dotnet
The above command, however, didn't work for me. It failed with the following error
The following packages have unmet dependencies: dotnet : Depends: libicu52 (>= 52~m1-1~) but it is not installable E: Unable to correct problems, you have held broken packages.
The error is quite self-descriptive, and the answer is to install libicu package. Ran the commnad
sudo apt-get install libicu-dev
The above command installed the libicu55 on my machine, whilst .Net core has a dependency on libicu52. Fortunately, the package is available for download here.
Once downloaded, the package can be installed by running
sudo dpkg -i libicu52_52.1-3ubuntu0.4_amd64.deb
Now that the pre-requisite is installed, installing dotnet is simply a matter of running the following
sudo apt-get install dotnet
The above worked for me this time around. To test that it installed correctly, just type dotnet new in a new folder. It will create files for your .net project.
Please Note: Make sure that you set permissions to execute downloaded files described in this post.
Saturday, 3 October 2015
The visual studio 2015 version of the extension is out today and can be download from here.
Please free free to use it and give your feedback.
Monday, 2 March 2015
Git continues to amuse me. There sheer options and versatility that you get in creating branches, merges and tracking commits, make it a such a powerful source code repository. It also means a steep learning curve for a lifelong TFSVC and VSS .
This is the first of a series of posts, I will write about some common start up mistakes I have done or seen others doing. I hope it would be helpful for the wider community.
To demonstrate my git repository clearly, I am using posh-git, which gives a view of my current git branch and also shows local, active and remote branches in different colours
Created branch but failed to created tracking information.
This is one of the most common mistakes. To describe it, I start with listing all my local and remote branch. To do that I type in “git branch –a” as shown
As you can see with the asterisk against master that my current local repository is “master”.
Now lets say that I want to work on the remote “TeamBuild/Staging” branch . To do that I created a new local branch naming it same as the server
The new branch is created successfully and I am switched on to the new branch as shown by running another “git branch –a”
You can see that the current branch is now switched to “teambuild/staging”. All good so far.
However, when I do a “git pull”, I got the following message.
So, what has gone wrong. A quick peek into the Git config file, tells me that the new branch is created without tracking it to the remote branch with the same name.
As you can see that there is no mention of the newly created branch.
The reason no tracking information was created is because Git is case sensitive. So, the branch“teambuild/staging” is not same as “TeamBuild/Staging”. For windows / TFS users, they look the same but Git would treat them as two separate branches.
You can add tracking information in a branch using the “git branch –u” command. So typing the following will add tracking information with the remote branch and you will be be up and running
You can see that the tracking information is added by peeking into the git config file. Notice the couple of lines in the end to see details of the /staging/teambuild branch added to git config.
Don’t try it at home
You will git into a bit of a pickle if are using Windows and you create two local branches that differentiate just by casing. Since git creates a folder within the refs/head folder in the git directory. If the names vary only by casing, it would have two branches tracked on one folder which would confuse it. So be mindful with casing while working with Git branches.
Monday, 17 November 2014
Shelveset Extension is a visual studio extension that I first published at the start of this year. The extension provides a functionality that is otherwise missing in both Visual Studio and Team Foundation Server that is to compare the contents of two shelvesets. I felt that need for it as our team used shelvesets to pass work around and tracking what has changed since the time a shelveset was taken was not always obvious.
There extension has proved popular I have been trying to keep up with comments and feedback on it. This update was due for some time. The view of the extension in team explorer has changed a bit to show options for typing in two users. This allows for comparing shelvesets between two users. However, unlike the first release of the extension, there is still one list to display all users. To separate out shelvesets of two users, an “Owner” column has been added. The column headers are made clickable as well and will sort the rows based on the clicked column.
Another feature added is the Options panel, allowing users to select whether they want to view the extension as a Team Explorer button or not. Another option is to hide the second user.
The options are there to allow users to customise the view as per their needs.
Apart from the new functionality, several fixes and performance improvements have been made
Going forward, there is going to be another release by the end of this year, where I will be adding feature to search on a shelveset name. There will be further optimisation in the performance when comparing the contents of two shelvesets.