Tuesday, December 20, 2016

How to use AppVeyor to build your .NET projects

Continuous Integration is a great thing. Among other things it allows you to automatically build and test your projects on every commit to VCS. Here I'll describe you how you can get advantages of Continuous Integration by using AppVeyor for free.

Personally I have several open-source repositories on GitHub. Certainly I build and test code on my development machine before pushing it to GitHub. But it would be great to automate this task. Wouldn't it be great if after each push we could build our project for several different environments and test it for all of them? Continuous Integration can do all of this and more.

But I don't want to pay for processing of my open-source projects. Can I get this functionality for free? Yes, I can.

I started from Travis CI. Unfortunately its support for .NET projects is not ideal. It uses Mono to build them on Ubuntu. Also for every build Travis creates new virtual machine, installs Mono, etc. It takes quite a lot of time.

But today I discovered AppVeyor.It took me only 5 min. to build my project from GitHub and run all tests. Here is how you can do it:
  • Log in into AppVeyor.
  • Create a new project:
  • Choose repository of your project from GitHub or another VCS. You may need to pass authorization procedure.
That's it. Your AppVeyor project is ready.  The only problem I faced is that by default AppVeyor does not restore NuGet packages for your project. But it is easy to fix:
  • Go to your AppVeyor project and open settings:
  • Go to Build tab:
  • Change "Before build script" from OFF to CMD and enter "nuget restore" into the text area:

That's it! You may enjoy automatic builds and tests!

But what about tests? I have not said a word about tests configuration. It is great that AppVeyor is smart enough to automatically discover your tests, identify your test runner (NUnit, XUnit, ...) and run them all!





No comments:

Post a Comment