Książka o Continuous Integration
May 3, 2009 on 9:53 pm | In MSBuild, Continuous Integration, Books, DotNet | 2 CommentsJednym z moich głównych zainteresowań zawodowych są procesy Continuous Integration. Jestem bardzo dumny z pełnego systemu ciągłej integracji, jaki uruchomiłem u mojego pracodawcy kilka lat temu. Od tego czasu regularnie w nim majstruję ulepszając to i owo. Niedawno pomyślałem, że lata mojej praktyki i doświadczeń z CI mogą przydać się innym. Po co ślęczeć nad problemami, które ja być może już rozwiązałem. Pomyślałem, że napiszę książkę. Poszukiwania wydawcy w Polsce sprowadzają się właściwie do jednego wydawnictwa - Helion. Mają oni bardzo ciekawą ofertę dla początkujących autorów. Wystarczy dostarczyć im ankietę autorską, szczegółowy spis treści i jeden rozdział a wydawnictwo rozważy podpisanie umowy z autorem i wydanie książki. Postanowiłem spróbować sowich sił. Bardzo roboczy tytuł mojej książki to „.NET Continuous Integration za pół darmo”. Ankietę autorską Wam podaruję, ale spis treści książki, którą chciałem napisać wyglądał tak:
1. Dlaczego continuous integration?
a. Automatyzacja = oszczędność
b. Nie najnowszy wynalazek
c. Bądź zawsze gotowy
2. Automatyzacja
a. Kompilacja w jednym kroku
b. NAnt kontra MSBuildc. Automatyzacja procesu budowy za pomocą MSBuild
3. System kontroli wersji
a. Sine qua non
b. VSS kontra SVN
c. Subversion w akcji
d. Dobre rady w sprawie porządku w projekcie
4. Serwer ciągłej integracji
a. Bez niego ani rusz
b. TFS kontra CC.NET
c. CruiseControl.NET w akcji
5. Testy jednostkowe
a. Testy najbliższe materii
b. VSTS kontra NUnit
c. NUnit w akcji
d. Badanie pokrycia testami za pomocą NCover
6. Kontrola procesu ciągłej integracji
a. Wiedzieć, co w trawie piszczy
b. CCTray kontra Dashboard
c. Obaj w akcji
d. Integracja raportów (NUnit, NCover) z Dashboardem
7. Testy akceptacyjne, integracyjne i systemowe
a. Z tysiąca stóp
b. Web: Selenium
c. Windows: NUnitForms
d. Testy Fitnesse
8. Analiza kodu
a. Konwencje są ważne
b. Statyczna analiza kodu w FxCop i StyleCop
9. Wersjonowanie
a. Gdzie ja jestem?
b. Rozszerzanie MSBuild
10. Dokumentacja
a. Nie lubiane dziecko projektu
b. Generowanie dokumentacji w Sandcastle
11. Dostawa
a. Zawsze gotowy
b. Publikacja za pomocą ClickOnce
c. Tworzenie instalatora w Visual Studio i WiX
Przykładowy rozdział książki dla wydawnictwa Helion ze zrozumiałych względów, nie może być wstępem. Zacząłem, więc od rozdziału drugiego. Traktuje on o podstawach MSBuild utrzymując w perspektywie jego wykorzystanie w procesie ciągłej integracji.
Oto kompletny rozdział drugi książki.
Tak przygotowaną zachętę do wydania przesłałem do wydawnictwa Helion. Niestety odpowiedź była odmowna:
„Dziękujemy za nadesłaną propozycję autorską, jednak bardzo mi przykro, ale nie zdecydujemy się na jej wydanie. Naszym zdaniem temat jest zbyt wąski, żeby mógł zapewnić satysfakcjonującą sprzedaż.“
Rozumiem i szanuję decyzję… ale naturalnie uważam ją za błędną ;-) To byłaby świetna książka. Jestem pewny, że sprzedałaby się w milionowym nakładzie i otrzymałbym za nią, co najmniej Pulitzera, a jeśli nie, to przynajmniej Nagrodę Jolt.
Tak wiec, jeśli jesteś przedstawicielem wydawnictwa, które byłoby zainteresowane wydaniem tej perełki to jestem otwarty na wszelkie propozycje!
Writing MSBuild Custom Task
March 13, 2008 on 8:16 pm | In MSBuild, Continuous Integration, DotNet | 9 CommentsScenario: we have Subversion server to manage our source code and a build server (CruiseControl.NET) to manage our deployment. We have decided to automatically set the SVN revision number to our assembly version.
[assembly: System.Reflection.AssemblyVersion(“1.2.3.0″)] [assembly: System.Reflection.AssemblyFileVersion(“1.2.3.0″)]
So we will replace the last 0 with the current Subversion revision number. How to do this? One way to achieve this is to modify the AssemblyInfo.cs and read the modified number from that exists. The file modification is easy with MSBuild Community Task FileUpdate
<FileUpdate Files=“Cic.P001001PropertiesAssemblyInfo.cs” Regex=“(d+).(d+).(d+).(d+)” ReplacementText=“$1.$2.$3.$(RevisionNumber)” />
But how to read it back? Well there is no easy way. I have written a custom MSBuidl task to achieve this like this:
<AssemblyInfoReader Path=“PropertiesAssemblyInfo.cs” Property=“AssemblyVersion“> <Output TaskParameter=“Value” ItemName=“ApplicationVersion” /> </AssemblyInfoReader>
Writing a custom MSBuild task is fairly easy. You have to Reference Microsoft.Build.Framework and Microsoft.Build.Utilities and implement Microsoft.Build.Framework.ITask. Just like this:
namespace Cic.MsBuildTasks { public class AssemblyInfoReader : Microsoft.Build.Framework.ITask { #region Private Varaibels private string path; private string property; private string value; #endregion #region Fields [Microsoft.Build.Framework.Required] public string Path { get { return path; } set { path = value; } } [Microsoft.Build.Framework.Required] public string Property { get { return property; } set { property = value; } } [Microsoft.Build.Framework.Output] public string Value { get { return this.value; } set { this.value = value; } } #endregion #region ITask Members private Microsoft.Build.Framework.IBuildEngine engine; Microsoft.Build.Framework.IBuildEngine Microsoft.Build.Framework.ITask.BuildEngine { get { return engine; } set { engine = value; } } bool Microsoft.Build.Framework.ITask.Execute() { string message; value = string.Empty; try { value = MyReadAssemblyInfoProperty(); message = string.Format( “AssemblyInfo property {0} read. Property value {1}”, property, value); } catch (System.Exception e) { message = string.Format( “Error reading AssemblyInfo property {0}. Error: {1}”, property, e.Message); } Microsoft.Build.Framework.BuildMessageEventArgs args = new Microsoft.Build.Framework.BuildMessageEventArgs( message, string.Empty, “AssemblyInfoReaderTask”, Microsoft.Build.Framework.MessageImportance.Normal); engine.LogMessageEvent(args); return true; } private Microsoft.Build.Framework.ITaskHost host; Microsoft.Build.Framework.ITaskHost Microsoft.Build.Framework.ITask.HostObject { get { return host; } set { host = value; } } #endregion #region Internals private string MyReadAssemblyInfoProperty() { string propertyValue; // Eraly return if (!System.IO.File.Exists(path)) return “”; foreach (string line in System.IO.File.ReadAllLines(path)) { if (line.Contains(property)) { try { propertyValue = line.Remove(0, line.IndexOf(‘”‘) + 1); propertyValue = propertyValue.Remove( propertyValue.LastIndexOf(‘”‘), propertyValue.Length - propertyValue.LastIndexOf(‘”‘)); // return matching property value return propertyValue; } catch { // Ignore errors } } } return string.Empty; } #endregion } }
Developing Vista Sidebar Gadget with Script#
January 19, 2008 on 3:08 pm | In MSBuild, Vista Sidebar Gadget, DotNet | 2 CommentsC# to JavaScript compiler? What? Jea! I thought the same way. It’s amazing what smart people can invent. My men is Nikhil Kothari with his Script#. What do I need the C# to JavaScript compiler for, you ask. Is IL not enough? Well think of enriching your ASP.NET web sites with JavaScript written in C#. Or using Ajax with scripts written in Visual Studio with Intelisense and refactoring. Or developing the Vista Sidebar Gadgets without writing a single line of code in Javascript!
I instantly lookd at the third possibility. since I have Vista on board I was thinking about writing my own Sidebar Gadget (you know the little programs written in HTML an JavaScript, sticked to the right side of your screen). Of course I wonted it to by at least useful ;-) I thought about writing a small Leasing Calculator. I had my leasing mathematics library ready, but it was written in C#. I didn’t feel like rewriting it in JavaScript - what for? So Script# was a blast for me. I had my Leasing Calculator gadget in view hours.
What do you need to start working with Script#:
1. download the latest binaries from Script# project page
2. install it
3. create new Visual C# -> Script# -> Sidebar Gadget project in Visual Studio
You will get quite useful project template. The inside of Content folder is your gadget. If you compile everything Script# will transform your C# into JavaScript and place it in this folder. The last thing you have to do is to copy this folder into your Vista Gadgets folder (C:\Users\user\AppData\Local\Microsoft\Windows Sidebar\Gadgets\). You will have to do the same every time you will compile. Surely it is something to automate. The easiest way is to use the Post-build event in your project and a small MSBuild script that will copy the needed files to the place they should by.
$(WinDir)\Microsoft.NET\Framework\v2.0.50727\msbuild.exe $(SolutionDir)build.msbuild
And use this script:
<Project DefaultTargets=“Deploy” xmlns=“http://schemas.microsoft.com/developer/msbuild/2003“> <PropertyGroup> <DeploymentFolder>YourVistaGadgetFolder.gadget</DeploymentFolder> </PropertyGroup> <ItemGroup> <DeploymentSourceFiles Include=“LeasingCalculatorContent***.*” /> </ItemGroup> <Target Name=“Deploy“> <RemoveDir Directories=“$(DeploymentFolder)” ContinueOnError=“false“></RemoveDir> <Copy SourceFiles=“@(DeploymentSourceFiles)” DestinationFiles=“@(DeploymentSourceFiles-> ‘$(DeploymentFolder)%(RecursiveDir)%(Filename)%(Extension)’)“/> </Target> </Project>
So you are equipped with fully functional development platform for Vista Sidebar Gadgets.
One more thing. I do think that writing a JavaScript in C# is a good idea ;) but if you are new to Sidebar Gadgets you probably would like to take one step by step tutorial. It would help to understand Gadgets on the low level an d will get you up to speed with Schipr# later.
Continuous Integration article in SDJ
September 3, 2007 on 7:24 pm | In MSBuild, Continuous Integration, DotNet | No CommentsI would like to invite all my polish speaking readers to online version of my article about continuous integration in .NET. It was published in July 2007 in Software Developers Journal. You can find it in the download section of SDJ web page. You can read there about:
- setting up CI server with CruiseControl.NET
- creating one click build script with MSBuild
- incorporating unit testing and code coverage into CI process
- using WebDashboard and CCTray to control the process
- introducing code analyze with FxCop
- creating install file and deploying the project.
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^


