Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

A daily build script for your project

, 8 Oct 2011
Rate this:
Please Sign up or sign in to vote.
A simple scripted solution to automate your daily builds (cost 5 minutes of scripting)
Daily builds are your friend[^], as Joel Spolsky puts it. I'd have to agree with that, and it turns out to be fairly easy to create a daily build server using a batch-file and a vbscript.
 
First; the batch file. We'd need to fetch the latest source code from the source control system. We're using SourceSafe[^] at work, and it can update the sourcecode on your harddisk using a simple DOS-command;
"C:\Program Files (x86)\Microsoft Visual SourceSafe\ss.exe" Get -R -I- $/SkyNet -GLC:\Users\Eddy\Documents\Source -YEddy,
Tortoise can do the same[^], of course.
 
Now that we got the new source, we'd need to build it. We can call the IDE using the commandline to do so;
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" "C:\Users\Eddy\Documents\Source\SkyNet.sln" /build Debug
 
Going a step further than building, you could also run your unit-tests using mstest.exe[^] (assuming that you're using the Microsoft environment for your unit-tests)
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe" /testcontainer:"C:\Users\Eddy\Sources\SkyNet\bin\Release\SkyNetTestStuff.dll" /resultsfile:"C:\Users\Eddy\Desktop\SkyNet TestResults.trx" >"C:\Users\Eddy\Desktop\SkyNet TestResults.txt"
 
You could even hook up FxCop[^];
"C:\Program Files (x86)\Microsoft Fxcop 10.0\FxCopCmd.exe" /project:"C:\Users\Eddy\Documents\FxCop Projects\SkyNet.FxCop" /directory:"C:\Users\Eddy\Sources\SkyNet\bin\Debug" /console /searchgac /console >"C:\Users\Eddy\Desktop\SkyNet FxCop Report.txt"
FxCop is a valuable helper, even if you only use it to find unused variables and dead code. You can exclude the rules that you're not interested in. You could convert the TRX format to HTML using a free tool[^].
 
Put these commands together in a batch-file, and you can build, test and analyze your project with a single action. What's more, you can use vbscript to send you the text-files by email[^] as a result.
 
Now you have a batch file to do your build (and unit-test, and perform statistical analysis) and a vbscript to email you these results. Hook it up into the Windows Task Scheduler[^] to run it once a day, and you'll receive mails like these:
Loading C:\Users\Eddy\Sources\SkyNet\SkyNetTestStuff\bin\Release\SkyNetTestStuff.dll...
Starting execution...
 
Results               Top Level Tests
-------               ---------------
Passed                SkyNetTestStuff.Memory
Passed                SkyNetTestStuff.Sudoku
Passed                SkyNetTestStuff.Monopoly
Passed                SkyNetTestStuff.Blackjack
Passed                SkyNetTestStuff.Chess
Passed                SkyNetTestStuff.AI
6/6 test(s) Passed
 
Summary
-------
Test Run Completed.
 Passed  6
 ---------
 Total   6
Results file:  C:\Users\Eddy\Desktop\SkyNet TestResults.trx
Test Settings: Default Test Settings
 

Microsoft (R) FxCop Command-Line Tool, Version 10.0 (10.0.30319.1) X86
Copyright (C) Microsoft Corporation, All Rights Reserved.
 
Loading C:\Users\Eddy\Documents\FxCop Projects\SkyNet.FxCop...
Loaded DesignRules.dll...
Loaded GlobalizationRules.dll...
Loaded InteroperabilityRules.dll...
Loaded MobilityRules.dll...
Loaded NamingRules.dll...
Loaded PerformanceRules.dll...
Loaded PortabilityRules.dll...
Loaded SecurityRules.dll...
Loaded SecurityTransparencyRules.dll...
Loaded UsageRules.dll...
Initializing Introspection engine...
Analyzing...
Analysis Complete.
Writing 205043 messages...
 
[Location not stored in Pdb] : warning  : CA1709 : Microsoft.Naming : Correct the casing of 'SkyNet' in namespace name 'SkyNet' by changing it to 'Skynet'.
 
(..and more)
Create a "daily build results" label in your email-client and create a rule to route those emails to the label.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Eddy Vluggen
Software Developer
Netherlands Netherlands
I'm a Delphi-convert, mostly into WinForms and C#. My first article is from 2001, extending the Delphi-debugger, which is still visible on the WayBackMachine[^] and even available in Russian[^] Smile | :)

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 9 Oct 2011
Article Copyright 2011 by Eddy Vluggen
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid