Running the Ubuntu VSTS Agent on Windows Subsystem for Linux (WSL)


I was playing with the new ASP.NET Core Template in Visual Studio 2017 and I thought it would be interesting to spin up a Linux Agent right on my Windows 10 Pro installation.

UPDATE:  September 5th, 2017 – Upgrade Git Client to 2.14.1 from 2.7.4

Turn Windows Features On or Off

You need to enable the following feature in Windows 10.  Perform the following steps:

  • Open Control Panel
  • Click on Programs (above Uninstall a program)
  • Click Turn Windows features on or off (under Programs and Features)
  • Scroll down the list of features and near the bottom of the dialog click on Windows Subsystem for LinuxWindows Subsystem for Linux

 

SNAG-3962

Turn Windows features on or off | Windows Subsystem for Linux

  • Click Ok
  • Wait for the feature to install and restart.
  • You then need to go to the Store and select a version of Linux to install

Ubuntu Installation

Open the Windows Store App, using the Search box type Linux and press enter, then select Get the apps

 

SNAG-3971

Linux on Windows? Totally?

 

Select Ubuntu

SNAG-3963

Windows Store | Run Linux on Windows

 

SNAG-0811

Ubuntu | Click Install

 

After the installation is complete you can start Ubuntu by selecting Launch which will be displayed in place of Install.  You can also start Ubuntu from a command prompt by typing ubuntu and pressing <enter>.  The first time you start Ubuntu you will have to wait a few minutes while it completes the installation.  You will have to create a default UNIX user account and password to complete the configuration.  If you need to run a command as administrator, use sudo <command>.

SNAG-0813

Ubuntu | Installation Successful

.NET Core 2.0.0

We need to have .NET Core installed in Ubuntu to configure the Visual Studio Team Services Agent.  This requires a few extra steps as documented here.  Here are the commands I executed:

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-get update
sudo apt-get install dotnet-sdk-2.0.0

 

SNAG-0815

Install .NET Core 2.0.0 for Ubuntu 16.04

 

Upgrade Git Client

You can update the client in Ubuntu to get rid of the following message during the Get Sources task

 

SNAG-3976

Upgrade your Git Version

 

Execute the following commands in the console to upgrade to 2.14.1

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

Here is a screenshot of the result

SNAG-3977

Now if you trigger a build, you will no longer see the message

SNAG-3978

Ubuntu Version and Font

You can check the version of your Ubuntu install #CheckyourUbuntuVersion using the command lsb_release -a

The version installed with the Ubuntu Store App is Release 16.04 at the time of this post.  If you want the Ubuntu font for your terminal you can download from here.  Install the font using the file named UbuntuMono-R.ttf by right clicking and selecting Install.

SNAG-0814

Install the VSTS Agent on Ubuntu

We need to go to GitHub and download the release for our operating system (Ubuntu 16.04).  You can find the releases here.  I will be downloading a pre-release tagged v2.122.0 for Ubuntu 16.04.

I used my browser to download the pre-release which means I need to access my downloads folder from within the Ubuntu terminal.  I can access my downloads folder at the following path /mnt/c/Users/Wes/Downloads/ (Note:  Directories and Filenames are case-sensitive)

Using the steps posted on GitHub as a guide, I executed the following commands inside the Ubuntu terminal to extract the agent into a folder named myagent.

mkdir myagent && cd myagent
tar xzf /mnt/c/Users/Wes/Downloads/vsts-agent-ubuntu.16.04-x64-2.122.0.tar.gz
ls -l

 

SNAG-0816

Extract the VSTS Agent

 

Now we are ready to configure the agent and connect it to our VSTS account.  To do that we use the config.sh command and provide the values requested.  Note: You will be required to supply a PAT (Personal Access Token) to connect the agent to your account.

If your repository is using TFVC make sure you answer Y to the question whether to install Team Explorer Everywhere.  See screenshot below

The values you will require are:

Server URL: https://{account-name}.visualstudio.com
Personal Access Token: See instructions here.
Agent Pool: default
Agent Name: Any name you'd like
Work Folder: _work

 

SNAG-0817

Config.sh

You can start the agent by executing the run.sh command shown above.  If all is well you can create a .NET Core build and configure it to use your default queue where the agent is configured and running.  Here is a screenshot of sample build I executed on the agent configured above.

 

SNAG-0818

ASP.NET .NET Core Demo Build Result

 

 

Hopefully I didn’t miss anything, of course feel free to leave a comment.

 

About wesmacdonald

Wes MacDonald is a Visual Studio ALM MVP, PSD, MCT and a Principal Consultant for LIKE 10 INC., a SharePoint Server, Visual Studio and Team Foundation Server Consulting Firm providing premium support and guidance services.

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: