Tuesday, April 20, 2010

Adding the build counter line to MSVS output

Sometimes it’s very important to know how much builds you have built.
Here is the simple way how to do it.
Everything you need is to make build counter console application.

Source code of buildcounter.cpp:
#include <stdio.h>

void main()
    FILE *file1 = fopen("build.txt", "r");
    int build = 0;
    if (file1) fscanf(file1, "%d", &build); else return;
    printf("Build %d\n", build);

    FILE *file2 = fopen("build.txt", "w+");
    if (file2) fprintf(file2, "%d\n", ++build); else return;
As you can see current build is written to the file build.txt.

Thereafter you need to add your buildcounter.exe to pre-build event command line.

Finally, you'll get the following result:

No comments:

Post a Comment