Continuous Integration (CI) with AppVeyor

melih orhan
inventiv
Published in
4 min readJul 2, 2019

In Inventiv, we decided to make our core library Routine (a UI and API framework for .Net) an open source repository hosted on Github.

Generally, big companies have separate teams for testing and DevOps, but we don’t have that lux. We want to automatize the build, package, test, and deployment of our project. When I navigate at Github repositories, I usually notice the Build icon and try to imagine the origin of it! We decided to use AppVeyor for the Routine project.

AppVeyor CI is a continuous integration and deployment platform for .NET applications. It makes much easier to test, deploy and monitor their builds for developers. It is free for open-source projects and could be easily integrated with GitHub and BitBucket.

In this post, I will mention the part of the Build of the Github repository.

First step, create an account on appveyor.com and connect a public repository.

Use GitHub button to sign up with your existing developer account (OAuth).

After a successful login with Github, you will see a list of current projects connected in your Github account.

In Main Menu, click on “New Project”.

As you can see it is possible to connect several platforms to AppVeyor, GitHub, Bitbucket, VSTS, and others. You will see a list of all the repositories in your Github account.

On this screen, click the “ADD” option on the right side of your project.

Your app will add appveyor project store and it will bring up a screen like below.

Your app now is connected. There are no special integration settings to enable on Github. Project builds can be configured by appveyor.yml

Add a .appveyor.yml file to the root directory of your repository. AppVeyor supports dot-file-style YAML named .appveyor.yml

You can specify the building and testing environment, etc. This file gives AppVeyor some details it needs to run our build process.

# configuration for "master" branch
-
branches:
only:
- master
configuration: Release
before_build:
- ps: nuget restore .\Routine.sln
build:
project: .\Routine.sln
# configuration for all other branches except "master"
-
branches:
except:
- master
configuration: Test
before_build:
- ps: nuget restore .\Routine.sln
build:
project: .\Routine.sln

The highlights of this file are:

  • Check configurations with branches/except section defined. If a branch is not found in the configuration’s exceptsection use this configuration.
  • Check configurations with branches/only section defined. If a branch is found in the configuration’s only section use this configuration.
  • Check configuration with configuration section defined. It specifies in which mode it will build. We configured Release mode on the master branch.
  • Check configuration with before_build section defined. You can execute scripts before building the project. In this section, we have restored NuGet.
  • Check configuration with build section defined. By default, AppVeyor works in MSBuild mode. This causes AppVeyor to look for a Visual Studio project or solution file in the root directory of your project, and use that to do the build.

You can follow all other details here.

You can validate your YAML configuration from here.

Add that file at the root of your project and commit it to Github. As soon as you do, Appveyor will try to run your project.

The build will take place and you can follow the steps through the console window.

Now, push to your repository make a pull request. Appveyor will run tests automatically and let you know if your code has passed or failed.

You can view the results in Github, or click on details and see the test as its running in your AppVeyor dashboard.

Finally, AppVeyor is integrated with our Git repository. So for each commit we make (or even a Pull Request) on Github, a build process is triggered and AppVeyor would use the configuration we defined in .appveyor.yml during the build process. If during the build process our test fails, we have a failed build. On the other hand, if all our tests pass, we have a successful build.

See you soon :)

References

--

--