The following requirements have to be met for creating a build job for a C# project.
- Running TeamCity instance (Setup manual can be found here)
- MS Build Tools have to be installed on the host (download)
- MS Test Tools have to be installed on the host (download)
Important: Restart the build agent after the installation of the MS Tools
Basic build job setup
This section describes the basic setup of a build job for a C# project on a TeamCity server. The LogShipper project, which is available on GitHub, will be taken as a sample project.
- Log in to your TeamCity server and go to the Administration board
- Click Create project from URL
- Select the parent project, enter the repository URL and the repository credentials
- Define the project and build config names
- Next, TeamCity will scan the source code and try to auto detect some build steps
- Choose the desired build steps out of the recommendations
- The build steps can now be configured by clicking on edit
Add build step for unit tests with MSTest
To add another build step for the execution of unit tests perform the following steps
- Go to the build configuration of the C#-Project
- Navigate to build step and add a new one
- Select MSTest
- Configure the unit test build step as desired
Trigger build on commit to VCS
For triggering the build job on every commit to the version control system (VCS) go to your build job/build configuration settings.
- Go to Triggers
- Add a new trigger
In the trigger configuration popup you can configure as well rules for the trigger like triggering the build only if a specific user commits or not triggering a build if the commit message matches a custom regular expression.
Store and sync configuration with VCS
TeamCity allows to store and its configuration to a VCS. The necessary steps are described below.
- Create a repository somewhere (i.e. GitHub or Bitbucket)
- Go to the administration board
- In Projects menu select the root-project
- Go to VCS Roots in left navigation
- Create a VCS root for the repository, where you want to store and syncronize the configuration to
- Go to Versioned Settings
- Select Synchronization enabled and choose the VCS root from the dropdown you created before (Step 5)