Skip to content

Building .NET Core 3 under a Linux TeamCity Agent

Sponsor: Do you build complex software systems? See how NServiceBus makes it easier to design, build, and manage software systems that use message queues to achieve loose coupling. Get started for free.

Learn more about Software Architecture & Design.
Join thousands of developers getting weekly updates to increase your understanding of software architecture and design concepts.


TeamCity Agent

I recently needed to (re)build a new TeamCity agent under Linux to build a .NET Core project. There wasn’t anything overly complicated but I figured I’d post everything I had to do in one spot since you have to dig around various/documentation to get it all working.

Hopefully, this helps anyone (including myself) in the future that needs to build a Linux TeamCity Agent for building a .NET Core app.

I’m using an EC2 instance in AWS using the Ubuntu 18.04 image. This is important because all the following steps are based around that and there are differences if you are using different distro or version of Ubuntu.

TeamCity Agent

The first step is to install the TeamCity Agent, you need a few packages before we can even do that including OpenJDK. The agent itself is just in a zip file you can download from your TeamCity server.

The next step is to configure the build agent to connect to your TeamCity Server, eg http://{TeamCityHostName}:{Port}. To do so, modify the buildAgent.properties with the correct values.

init.d

To create a start/stop script, you’ll create a new file /etc/init.d/teamcity with the following contents. Make sure to replace the USER and the path to the buildAgent directory we unzipped earlier.

Once that’s done, make sure the file is executable and we’ll configure the default priorities.

.NET Core SDK

To install the .NET Core SDK is pretty straight forward.

Mono

As a bonus, here’s how to install Mono. I also needed this to run my Cake build scripts.

Hopefully, you find this useful. If there any steps or any additional sdk’s that should be included please let me know in the comments or on Twitter. I suspect I’ll create a docker image and put this on Docker Hub if anyone has any interest.

Related: Using Date Version Numbers for Assemblies in TeamCity

Learn more about Software Architecture & Design.
Join thousands of developers getting weekly updates to increase your understanding of software architecture and design concepts.


Leave a Reply

Your email address will not be published. Required fields are marked *