Automated Build Usage Example

A problem

Do you have a manager on a project? Does (s)he use Visual Studio to review new versions?

For me the answer was Yes for the both above questions on the last project I was involved on.

It’s a real pain to start Visual Studio just to build an run application, isn’t it? I think so, since to be honest it will take a while…

  • Wait Visual Studio to be started
  • Get latest source code
  • Wait until Visual Studio will load a project
  • And finally we need to build a project.

A solution

You know I think it’s not fair to ask manager to do all of this… Smile

There are several ways to simplify our Project Manager’s life. In case if you are using Continuous Integration (CI) the solution is simple – manager can just download latest version from the CI server. So (s)he will just download a build, unpack it and that’s it – (s)he ready to start app! Sure as further improvement we can create a batch file which will automate above 3 steps. Since it would be much easier to just run one single batch file and see application running.

But what if you don’t use CI currently? Yes we all now that we Should use CI, but sometimes we just can’t. But we always can add Automated Build Script to our solution. And we will be able to provide the same “Click Once” approach as in case of the CI server in charge.

Example

Let’s assume that we use SVN as a source control. And we have MSBuild build script which can

  • Build project
  • Run tests
  • Start application

In that case all we need is the following simple Batch file:

Tiny Explanation

I think it’s pretty straightforward but here’s some notes.

  • BUILD_FILE_NAME_GOES_HERE – is a placeholder for the actual build script. For example HelloWorld.build
  • TARGET_GOES_HERE – is a placeholder for the Target which will build project, run tests and then start application

Above build script will silently try to get latest source code using TortoiseProc (a part of the TortoiseSVN) in case if it installed. In other case source code should be updated manually. Actually this part could be improved in many ways. For example we could check if SVN console client is installed.

After than build script will check if it able to locate MSBuild and if yes it will run it.