Continuous Integration in .NET book MEAP update
January 21, 2010 on 6:11 pm | In DotNet | No Comments
There are two new chapters available at Manning MEAP site. The third one about build process automation (with MSBuild) and the forth one about choosing the right CI server (covering CCNet, TeamCity and TFS 2010).
And wow the book is third on this weeks bestselling early access titles. Juhu!
Speaking about continuous integration
January 16, 2010 on 7:09 pm | In Continuous Integration, DotNet | No Comments
I will be speaking on Wednesday (20.01.2010) in Krakow, Poland at the Karkow .NET Developers Group meeting. The session is about Continuous Integration in .NET. So if you like hear what I have to say about CI meet me at ABB ISDC, Pałac Pugetow, ul. Starowislna 13, Krakow at 18:30. I believe the attendance is free but registration is required. See you in Krakow!
Selenium RC and FitNesse as a service on Windows Server 2008
November 7, 2009 on 10:19 pm | In Windows, Continuous Integration, DotNet | No CommentsIf you are working in a team or running a continuous integration process the most comfortable way to run tools like Selenum RC Server or FitNesse is to install them as a windows service. I was doing this earlier on my old Windows Server 2003 by issuing the instsrv.exe (to install a service) on srvany.exe (to run anything) - both from Windows Resource Kit. I had to edit the registry to provide what exactly do I wanted to run (java –jar selenium-server.jar or java –jar fitnesse.jar).
But there is no Windows Resource Kit for 2008. You might use the sc.exe and get the old srvany.exe (with compatibility issues according to Microsoft itself). It would work but why bother when there is a Non-Sucking Service Manager! All you have to do to install a service with this tool is to download it, issue a
nssm.exe install SeleniumRC
and edit this dialog box:
Click Install service and you are done. Selenium RC Server is installed. All you have to do is to start it. Voila!
How to make CruiseControl.NET accept SSL certificate under Windows Server 2008?
October 24, 2009 on 11:44 pm | In Windows, Continuous Integration, DotNet | No CommentsIf you are running CruiseControl.NET under the Local System account and your SVN server certificate was issued by yourself (or by VisualSVN Server) you will quickly run into trouble. Normally if you run any command on your repository you will get this information:
C:\Program Files\svn\bin>svn log https://your_server/svn/your_repository/trunk –username username –password password
Error validating server certificate for ‘https://your_server:443′:
- The certificate is not issued by a trusted authority. Use the
fingerprint to validate the certificate manually!
- The certificate hostname does not match.
Certificate information:
- Hostname: your_server
- Valid: from Sat, 26 Sep 2009 17:24:27 GMT until Tue, 24 Sep 2019 17:24:27 GMT
- Issuer: your_server
- Fingerprint: 24:8e:f6:ba:c7:a6:3f:69:32:c0:21:92:64:44:62:fe:2c:bb:b4:69
(R)eject, accept (t)emporarily or accept (p)ermanently?
If you accept you will not be bothered again. But CCNet works as a Windows Service. There is no one to make the decision. How to deal with this issue. Well earlier it was easy enough. You had to use one of the security holes and start cmd.exe in interactive mode wit at command (look here for more details). But with Windows Server 2008 it is not possible you will simply get this:
C:\Users\Administrator>time
The current time is: 23:31:11.59
Enter the new time:
C:\Users\Administrator>at 22:32 /interactive cmd.exe
Warning: Due to security enhancements, this task will run at the time
expected but not interactively.
Use schtasks.exe utility if interactive task is required (’schtasks /?’
for details).
Added a new job with job ID = 1
How to deal with this. There is very easy solution. Set the CruiseContril.NET service “Allow to interact with desktop” flag (Start –> Control Panel –> Administrative Tools –> Services –CruiseControl.NET) like this
Restart the service and wait a while for this windows to appear:
Select show me the message.
Voila! You have command line as Local System user available. You can now issue the
C:\Program Files\svn\bin>svn log https://your_server/svn/your_repository/trunk –username username –password password
command and accept the SSL certificate permanently.

From this time on you CCNet server will not have any problems with accessing your secured repository.
Buy Continuous Integration in .NET book
October 19, 2009 on 7:52 am | In Continuous Integration, Books, DotNet | 2 CommentsThe Continuous Integration in .NET book is available as an early access edition from MEAP. For those of you that are not familiar with MEAP it stands for Manning Early Access Program and it is the place where you can download a free chapter and buy the whole book printed or as an ebook before it gets published. You will get continuously chapter after chapter successively as they will be written.
Get Oracle stored procedure object output in NHibernate
September 5, 2009 on 5:24 pm | In Oracle, DotNet | No CommentsI’ve wasted view hours on this so I think I share in case you have a similar problem.
We are working with Oracle Database and .NET project using NHibernate as a object-relation mapper. We have a function in Oracle that returns an Oracle Object. Objects in Oracle are user defined types. They are defined like this:
CREATE OR REPLACE TYPE Foo as object(
Value1 number,
Value2 date,
Value3 varchar(10)
);
And now Oracle Function with signature like this:
CREATE OR REPLACE FUNCTION Bar (id int)
return Foo pipelined
This function returns a Foo object and gets the id key from a table VT (some table). The 3 values from Foo object should extend an NHibernate VT object. So I want to have 3 new properties in the NHibernate entity.
Sound easy? Well it wasn’t for me. At first how to get the values? You can get an instance of IDBConnection down from NHibernate context and fight your way with ordinary ADO.NET (which is not so easy for functions with user defined return values – at least I don’t know how to do this). But you can use a TABLE() function of Oracle. You can issue this SQL select statement:
select * from Table(Bar(1))
It will return a result set as a table you can select from. Cool stuff! But to use it you have to know it exists ;)
Ok, now the easy part. I though. I define a property in NHibernate with a formula attribute and I will map this on a property in my class. Something like this:
<property name=“Value1” type=“Int64” formula=“(select Value1 from Table(Bar(id)))“> </property>
Not so easy! If you do this you will get the Oracle exception. NHibernate thinks that Value1 from your formula is a part of NHibernate object and gives it a suffix. It is transformed to something like that:
select _vt0.Value1 from Table(Bar(4711))
_vt0 being the object alias. It is obviously not the case. There is no Value1 field physically in the database. There is a custom made property with SQL formula in NHibernate. As you can se the id was translated to actual key in the table.
The general rule for the formula attribute is everything tat NHibernate does not understand is send direct to database as is. The trick was to make NHibernate think it does not understands the statement completely.
The answer is to enclose Value1 with quotation marks. To achieve this you will have to use the XML escape marks. Just like this:
<property name=“Value1” type=“Int64” formula=“(select “Value1” from Table(Bar(id)))“>
A lot of tiny puzzles to put together. But it works!
Next big thing – continuous integration book
August 14, 2009 on 9:39 pm | In Continuous Integration, Books, DotNet | 3 Comments
I’m going to write a book about Continuous Integration in .NET for the Manning Publications. I’m sure I don’t have to tell you how exited am I. I will join the noble team of Manning authors like John Skeet, Ayende Rahien or Roy Osherove. I’ll keep you posted about the progress. In the mean time let me give you some history.
I’ve once written an article for Software Developers Journal about Continuous Integration in .NET. It was very well received. I always thought I have a lot more to say in this topic. The idea to write a book came while speaking with my good friend hsd (well I have more and more to thank you for :). I’ve tried to propose the book to a polish publisher Helion. Very fortunately for me they said there is not enough place on the polish marketplace to get enough sell (I’ve blogged about this in polish). I presume they know better. I’ve already buried the idea about the book when I saw the ASP.NET MVC 1.0 Quickly book from Packt Publication. It was written by a guy from Belgium (Maarten Balliauw). I’ve read his blog and I realized has not native English speaker. “If he can, why not to try myself?” I thought and written a short proposal for Packt. They were interested! I’ve worked on the proposal with the Acquisition Editor and I’ve shortly after that I’ve got the information that the book was “committed”. I was very, very happy until something went wrong at Packt (the went scared by a download stats of one of the tools I wanted to write about). The book was “uncommitted” and we didn’t sign the agreement. I don’t throw my hands up! I thought if they are interested probably someone else will be too. I’ve send view more proposals to other publishers and the Manning appeared. In the mean time Packt turned to be after all interested in me writing the book. The Acquisition Editor at Packt Publishing was a great guy. I’m sure it would be great to write a book for them but it was to late. Manning found me a co-writer Craig Berntson. Someone that speaks English a lot better than I and has a know how in continuous integration. The way the Manning deals with his authors seems very provisional and I’ve very glad to get this opportunity.
So be aware. The best Continuous Integration in .NET book comes sooner than you expected!
ASP.NET MVC custom binder for currency
June 24, 2009 on 8:05 am | In ASP.NET MVC, DotNet | 1 CommentI can imagine that’s quite common problem. You have a double (or better decimal) value that you want to show formatted as a currency field. Lets assume we are storing the price data in an object like this:
public class TestModel { public double NumberField { get; set; } public double CurrencyField { get; set; } }
The MVC view is strongly typed with this TestModel. And the view model value is formatted like this:
<%=Html.TextBox(“NumberField”, Model.NumberField)%>
<%=Html.TextBox(“CurrencyField”, Model.CurrencyField.ToString(“c”))%>
If you set the current culture to German-Swiss, for example in (base)controller like that:
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); string culture = “de-CH”; CultureInfo ci = CultureInfo.GetCultureInfo(culture); Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci; }
Done so we will get a text boxes looking like this:
What will happen if you use a default binder to get this value? The default binder will try to parse the string as a double value and get an ModelState error. The string does not represent a double value.
To deal with this issue we have to write our own model binder. This can be done by implementing the IModelBinder. But I don’t want to reimplement this how DefaultModelBinder reads other values than my currency doubles. So I though I will set a special attribute to the “special” properties. Something like this:
[AttributeUsage(AttributeTargets.Property)] public class CurrencyAttribute : Attribute { }
And my object:
public class TestModel { public double NumberField { get; set; } [Currency] public double CurrencyField { get; set; } }
And now we can overload the DefaultModelBinder and implement our TestModelBinder like this:
public class TestModelBinder : DefaultModelBinder { public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { object bindingObject = base.BindModel(controllerContext, bindingContext); foreach (System.Reflection.PropertyInfo propInfo in bindingObject.GetType().GetProperties()) { object[] attributes = propInfo.GetCustomAttributes(typeof(CurrencyAttribute), false); foreach (object attribute in attributes) { CurrencyAttribute currAtt = attribute as CurrencyAttribute; if (currAtt != null) { bindingContext.ModelState[propInfo.Name].Errors.Clear(); string attempted = bindingContext.ValueProvider[propInfo.Name].AttemptedValue; CultureInfo ci = bindingContext.ValueProvider[propInfo.Name].Culture; propInfo.SetValue( bindingObject, double.Parse(attempted, NumberStyles.Currency, ci), null); } } } return bindingObject; } }
And now we have to set the attribute to our object to tell MVC that it has to use your binder.
[ModelBinder(typeof(TestModelBinder))] public class TestModel { public double NumberField { get; set; } [Currency] public double CurrencyField { get; set; } }
Done! Although there are a view issues with this solution (if you are using Entity Framework you cannot set custom attributes, and in the binder above you will have to implement checking if the field is present on the view), but you get the general idea!
Easiest way to have 2 submit button in one html form
June 12, 2009 on 4:41 pm | In JavaScript, DHTML, DotNet | No CommentsHere is the easiest way to have two (or more) submit buttons in one html form and to make them “do” something else. It is very helpful if you are planning to implement a toolbar like behavior. Example is from ASP.NET MVC but it does not matter. Since it uses JavaScript to dynamically change the action attribute of a form tag, it can be used everywhere. Here it is:
<h2><%= Html.Encode(ViewData[“Message”]) %></h2> <script language=”javascript” type=”text/javascript”> function ChangeFormAction(sender, url) { sender.form.action = url; } </script> <form method=”post”> <input id=”text” name=”text” type=”text” value=”Hello from Action” /> <br /> <input type=”submit” value=”Go to action 1″ onclick=”ChangeFormAction(this, ‘/Home/Action1′)” /> <input type=”submit” value=”Go to action 2″ onclick=”ChangeFormAction(this, ‘/Home/Action2′)” /> </form>
And the actions that responds to this form are here:
public class HomeController : Controller { public ActionResult Action1(string text) { ViewData[“Message”] = text + “1″; return View(“Index”); } public ActionResult Action2(string text) { ViewData[“Message”] = text + “2″; return View(“Index”); } }
Nice!
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!
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^


