Tuesday 30 December 2008

NAnt HowTo #2: How To Split Your Build File

Let's assume you have a large build file with many-many targets, properties, etc. After some time it becomes pretty hard to support and extend it. What can we do? As for me, the best option here is to split your build file to several pieces. Below goes an example on how you can do this.

My default.build file:

<?xml version="1.0"?>

<project
name="NAnt HowTo 2" default="all" xmlns="http://nant.sf.net/release/0.85-rc2/nant.xsd">
<!--
Includes -->
<include
buildfile="build.include" />
<include
buildfile="test.include" />

<target
name="all" description="Default target, calls all deployment tasks.">
<call
target="rebuild" />
<call
target="test" />
</target>

<target
name="rebuild" descripton="Rebuilds all projects." >
<call
target="clean" />
<call
target="build" />
</target>

<target
name="test" description="Runs all tests.">
<call
target="tests.unit.run" />
<call
target="tests.integration.run" />
</target>
</project>
build.include file:
<project xmlns="http://nant.sf.net/release/0.85-rc2/nant.xsd">
<target
name="clean">
<echo
message="Rebuild: clean" />
</target>

<target
name="build">
<echo
message="Rebuild: build" />
</target>
</project>
test.include file:

<project
xmlns="http://nant.sf.net/release/0.85-rc2/nant.xsd">
 <target name="tests.unit.run">
<echo
message="Test: unit tests" />
</target>

<target
name="tests.integration.run">
<echo
message="Test: integration tests" />
</target>
</project>
As you can see, actual inclusion takes place when you use <include> element and specify it's buildfile attribute to point to some .include file.

.include
files should contain root <project xmlns="http://nant.sf.net/release/0.85-rc2/nant.xsd"> element with necessary xmlns attribute. Without this attribute NAnt won't be able to parse this file and use it's targets.

Included files become a piece of main build file and share all properties with it. This means that properties from included file are visible in main file and vise-versa. I usually place commonly used properties to separate .include files, for example, I have projects.include file with all properties that point to project names and folders.

kick it on DotNetKicks.com

Monday 29 December 2008

NAnt HowTo #1: How To Compile A Project?

NAnt provides a CSC task that will allow you to compile your C# project (sorry, VB guys, no info for you :)). It may be used this way:

<!--  2. Building shared data project -->
<csc
target="library" debug="false" warnaserror="true"
output="D:/projects/MyProject/Integration/MyProject.dll">
<sources
basedir="D:/projects/MyProject/Source">
<include
name="**/*.cs" />
</sources>

<references>
<include
name="D:/projects/MyProject/External/NHibernate.dll" />
</references>

<resources>
<include
name="D:/projects/MyProject/Source/NHib/*.hbm.xml"/>
</resources>

<nowarn>
<warning
number="1702" />
</nowarn>
</csc>

So let's have a look in details at each part of this task.

Attributes

One by one:
  1. target="library" - indicates that we want to have a .dll as result of our compilation. Possible values are exe, winexe, library or module.

  2. debug="false" - indicates that no debug symbols will be included into our assembly. Possible values are Enable, Full, None and PdbOnly. Although you can use aliases (like I did): true stands for Enable and false stands for None.

  3. warnaserror="true" - has same effect like checking 'Treat warnings as errors - All' option in Visual Studio. All warnings will be treated as errors.

  4. output="D:/projects/MyProject/Integration/MyProject.dll" - output of compilation. Make sure your output target extension is adequate to your compilation target (although I haven't tried compiling target library to output .exe :-P)

Sources

This nested element allows you to select files that should be compiled. It's only attribute I use here is:

basedir
="D:/projects/MyProject/Source" - base directory for source files. Usually this is root folder for some project.

The <include> element allows you to specify elements that should be compiled. It's attribute, name, deserves some attention. First, it uses wildcards to pick necessary items. Second, it uses double asterisk to recursively pick all files from all folders. Have a look:
  1. name="*.cs" will pick .cs files only in current folder

  2. name="**/*.cs" will pick .cs files from current folder and from all subfolders, their subfolders, etc.

References

This nested element allows you to specify assemblies that should be references. Syntax also supports wildcards so you can easily specify *.dll to reference all .dll files in some folder.

Resources

This element allows you to deal with resources embedded into your assembly. In this particular case I use this element to embed NHibernate .hbm mappings.

Nowarn

This section allows you to ignore some specific warnings via nested <warning /> element. Use it's number="1702" attribute to specify some specific warning you want to ignore.

Conclusion


That's a short explanation on CSC target, more information can be found here. Hope this post will be helpful to anyone other than myself :D

kick it on DotNetKicks.com

NAnt HowTos

Lately I had to dive into NAnt and I'm going to post here several posts on some simple NAnt questions.

Wednesday 24 December 2008

Things to complete

Here goes the list of things I want to complete in the nearest future:

  1. Master ASP.NET MVC
  2. Become senior software engineer at next internal attestation
  3. Dive deep into .NET attributes programming
  4. Master JQuery

How to become a better specialist?

Work with those who are smarter and more professional than you. This is a modified quote from some chess book and it applicable to literally any profession.

Applying this statement to my profession (I'm a .NET developer if anyone could have forgotten that ;)), you can become better much faster if you work with someone more qualified than you. I've been working with two nice developers for almost six months and now I can see my level is growing way too faster than if I would increase my skills myself. I'm actually approaching their level, day after day.

That's why in one of my dreams I imagine myself working together with such persons like Martin Fowler or Scott Guthrie. That could be a real experience boost!

Sharp Architecture

Do you want to become a better developer? Try this project. Yes, just download it and read the code. Comments are marvelous, design is outstanding. I love it. I've picked several tricks and two absolutely new libraries/approaches for myself.

Although it's designed to use with ASP.NET MVC beta you'll easily grab NHibernate code as it was designed not to depend on view framework.

Just try it

Tuesday 23 December 2008

ASP.NET Form Autocompletion

Our customer was really interested in enabling autocompletion feature for registration page. I've searched a lot, I've found a huge number of pages describing how to turn it off and (at last!) only one page about how turning it on.

All magic is hidden in AutoCompleteType property of asp:TextBox. You can read about it in details here but in a nutshell this field allows you to specify what information should be autosuggested for this particular TextBox.

Enjoy!

Thursday 18 December 2008

Internet Explorer 8 Release Candidate 1

According to a friend of my friend, IE8 RC1 has been accessible for Microsoft partners a month ago :( And seems like:

  1. No standards
  2. Slow JavaScript
  3. Security problems
  4. 17 in ACID3

I hope it was very old build. VERY old.

=(

Leaves Bugs System

Are you satisfied with Bugzilla? My answer is NO. I know it's has many nice features but I'm absolutely disappointed with it's UI. How could anyone create such a crap?! It's unusable and usually I spend up to 10 minutes to search for defects assigned to me for some specific iteration.

I saw nice solutions, but all of them had some drawbacks that made me drop using them off. One of these drawbacks was the price =). Anyway, me decision is to create something of my own. And as it is my graduation project, I have to complete it.

I'll develop it on top of the ASP.NET MVC Beta, NHibernate as my ORM (I'm disappointed with the EF at the moment) and JQuery as a great accelerator for UI. I'll try to follow best practices, including TDD and CI. Hope this will be a nice project ;)

Yesterday I've created some basic folder structure and started writing NAnt script for my new solution. I've also set up SVN server and added my projects to subversion. If everything goes fine I'll manage to set up CI at the earliest stage possible - and that's a good point. And later on - no step without TDD :) It's just too good to work without it.

New info coming soon!

Web Developer Wish List

Nice article on what you may ask for Christmas :) My choice is office chair - together with other 55 people who voted the same.

View wish list

IE 8 coming soon!

Or at least it's release candidate :) That would be a great Christmas present!

Read here

Wednesday 17 December 2008

New Live Writer

Could you image what could be better for blogging than Microsoft Live Writer? Earlier I could not, but now I see how I was mistaken :) And the answer is...

Live Writer 2009!!!!

Actually, this is just a release candidate, but the list of improvements looks fine:

  1. Support for YouTube
  2. Support for Flickr
  3. Spellchecking for some more non-English languages
  4. Support for Digg
  5. Support for Twitter

Waiting for release =)

Tuesday 16 December 2008

Chrome vs IE 8 Beta

This article shows that IE8 Beta loses the battle to Google Chrome. I think that it's mostly because of BETA in IE 8 name and Google Chrome has recently dropped same suffix.

Hope IE8 wins =)

Ruby-based barmen DSL

It's wonderful!

Just have a look at this sexy code:

drink 'Screwdriver' do
serve_in 'Highball Glass'
ingredients do
2.ounces :vodka
5.ounces :orange_juice
end
end


 



I like it! And you? ;)

Some interesting links

  1. It Oxite as good as it's claimed to be? According to this well-proved article, it's not and, moreover, it will hurt ASP.NET community.
  2. How your team goes agile? Our team tries to be agile but it's not a one-second process and it takes some time to adapt from previous techniques to agile methodology. That's why I really like articles about other agile teams as I can pick some interesting thoughts on agile from them. From this article I've actually taken four thoughts (2 absolutely new, 2 I knew earlier fundamentally explained)
  3. Some new Ruby book, available free in e-book format.

Monday 15 December 2008

Best text editor for Windows I've ever seen

Yes, that may sound too promising but whatever. I tried it and it's sexy. Nothing wrong, everything is extremely cool. I love it.

So, what is it? What is this wonderful sexy text editor? Here it goes: Intype. Check it here.

Snippets are sexy, UI is sexy, logo is sexy. It's SEXY!

Wednesday 10 December 2008

Ruby is FAST!

That's what I'm talking about. Ruby 1.9 is almost five times faster comparing to Ruby 1.8.6. Isn't it great? Perhaps this fact will make me turn back to Ruby from Python and will help me making my decision on platforms I use.

I'm aiming to have two platforms by my hand and for my purposes. The first one is definitely .NET - the one I'm going to use for large enterprise solutions. The second one is something I'm not sure about. I do know the main purpose of it though: this platform should be cross-platform, built on top of some script language and be easy to use for some lightweight solutions like a small e-shop or anything alike. Current variants are:

  1. Ruby with Ruby on Rails or Merb
  2. Python with Django or Pylons
  3. Objective-J with Cappuccino

I'm a devoted fan of Ruby and if Ruby's speed is not a problem anymore I'll definitely turn back to Ruby. That's why I meet all such kind of news with great inspiration and hope.

Monday 8 December 2008

The power of shell

Finally I've found some time to download and have a look at PowerShell - Microsoft replacement for it's old-ugly-non-usable command line prompt. And all I can say is GREAT! It's absolutely wonderful in it's might! Predefined aliases make it look like *UN?X shell and make it more usable.

Also take a look at PSTOOLS tool from Mark Russinovich - another great set of tools. As for me, I really like writing this:

pskill firefox

And this will actually kill firefox process. Isn't it wonderful? :)

Friday 5 December 2008

Calling .NET libraries from IronRuby

In my recent post on IronRake I've used the following task to demonstrate the power of IronRake:

task :default do
  require 'mscorlib'

  require 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
  print System::Guid.NewGuid().ToString()
end

And now I can tell you that everything is much simpler that that. Don't use "require" plus full assembly name. Use the following:

require 'mscorlib'

task :default do
    include System
    print Guid.NewGuid.ToString
end

"Include System" is much shorter, isn't it? :)

John Lam Talk on PDC

Yesterday I started viewing IronRuby video from PDC by John Lam. It's marvelous! I did know Ruby is a powerful language, I did know .NET is a powerful framework but I could not imagine how powerful IronRuby will be!

I recommend this video to anyone interested in IronRuby, you'll see many interesting things there.

Thursday 4 December 2008

Python 3 released

You can download it here.

Recently I've been diving into Python 3 rc3 and I can say that I like it. It is not as verbose as Ruby is but it's much simpler and _faster_. You know, I mean, FASTER. So my choice is using Python for some lightweighted websites (e.g. for my freelance tasks) and IronRuby for some huge websites.

Running IRake

This post will show you how to setup and run irake and feel incredible power of great tool written in great language that runs in great framework.

NOTE: in this post I assume all paths are correct and you can write 'rake' instead of 'd:/ruby/bin/rake'.

First, download IronRuby alpha 2. Unpack and have a look what we have. In /bin folder we have some executables, including iirb and irake. We're actually interested in second one. Let's create a simple task to try it!

task :default do
print 'rake is up and running!'
end

Let's try how it works with simple rake:

>rake

rake is up and running!

Cool. Let's try irake:

>irake

unknown: Could not find RubyGem rake (>= 0)
(Gem::LoadError)

Ok. Let's install it. As we are using irake we should use igem.

>igem install --remote rake


ERROR: While executing gem ... (System::IO::DirectoryNotFoundException)
Could not find a part of the path 'D:\External\languages\ruby\ruby-1.8.6\lib\ironruby\gems\1.8\gems\rake-0.8.3\bin\rake'.

That's the trickiest part of all. This path is not configurable (at least I could not find it), so we'll have to place ruby just where program expects it to find. What is interesting, this folder is already created. We'll install ruby 1.8.6 and copy it to this tricky folder ("D:\External\languages\ruby\ruby-1.8.6").

After that, let's try to install rake once again.

>igem install --remote rake


ERROR: While executing gem ... (System::IO::DirectoryNotFoundException)
Could not find a part of the path 'D:\External\languages\ruby\ruby-1.8.6\lib\ironruby\gems\1.8\gems\rake-0.8.3\bin\rake'.

Argh! What's wrong now? Let's check the path once again. Oops, 'rake-0.8.3' folder contains no 'bin' folder but only the following files:

CHANGES
install.rb
MIT-LICENSE
Rakefile
README
TODO

So this means rake is actually not installed even in native ruby. Let's do it.

>gem install --remote rake


Bulk updating Gem source index for: http://gems.rubyforge.org
Successfully installed rake-0.8.3
Installing ri documentation for rake-0.8.3...
Installing RDoc documentation for rake-0.8.3...

Ok, fine. Copy installed rake folder to ':\External\languages\ruby\ruby-1.8.6\lib\ironruby\gems\1.8\gems\rake-0.8.3\'. Going back to igem...

>igem install --remote rake


Successfully installed rake-0.8.3
1 gem installed
Installing ri documentation for rake-0.8.3...
Installing RDoc documentation for rake-0.8.3...
Error in template: Index was out of range. Must be non-negative and less than the size of the collection.

Parameter name: index
Original line: <td>%dtm_modified%</td>

Even some error can't upset us seeing line 'Successfully installed rake-0.8.3' =) So let's try irake in action:

>irake


(in D:/information/projects/ironruby)
rake is up and running!

Wonderful :) Irake is up and running. The last thing to do is to is to show that irake is not rake and can work with standard .NET library. Let's modify our rake task to use some .NET code:

task :default do
require 'mscorlib'

require 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
print System::Guid.NewGuid().ToString()
end

Making sure this task doesn't work in standard rake:

>rake


rake aborted!
no such file to load -- mscorlib

And, finally:

>irake


df2869e8-6b24-49d4-8915-424028b9871e

Conclusion:
We've installed irake, configured it to work and wrote a small task that works in it but not in standard rake. Later on I'll try to port some compilation tasks to irake and switch to it from nant in my projects.

Note:
For now, irake call is MUCH slower, than rake call. Hope later on IronRuby guys will speed it up.



kick it on DotNetKicks.com

Wednesday 3 December 2008

IRake works!!!

YAHOO!

Later on I'll post here how to make it work and feel power of IronRake.

Upcoming Add-on-Con at Mountain View

According to this page IE 8 developers will possibly make crossbrowser extensions creation as simple as it could be. Nice move, actually. Hope this aspect of extension creation will be treated by extension creators just like web developers treat writing crossbrowser websites. This means most good Firefox extensions will be fortunately ported to IE 8 and users will be able to switch to the latter with minimal troubles.

Tuesday 2 December 2008

Fowler on Rake

A quote from wonderful article:

So far I've found rake to be a powerful and easy to use build language. Of course it helps that I'm comfortable in ruby, but rake has convinced me that a build system makes sense as an internal DSL to full-blown language. Scripts are a natural for building stuff in many ways, and rake adds just enough features to provide a really good build system on top of a fine language. We also have the advantage that ruby is an open source language that runs on all the platforms that I need.

I was surprised by the consequences of flexible dependency specification. It allowed me to do a number of things that reduced duplication - which I think will allow me to make it easier to maintain my build scripts in the future. I found several common functions that I pulled out into a separate file and shared between the build scripts for martinfowler.com and refactoring.com.

If you're automating builds you should take a look at rake. Remember that you can use it for any environment, not just ruby.

Rake forever :)

Python 3.0 rc3

Yesterday I've installed release candidate #3 for Python 3.0. My expectations were high enough and as with all high expectations I did not find what I was intended to find. 'self' in method signatures is still there, for example :( I'll continue my investigations by all my enthusiasm has gone.

Another not very good news is that Python actually doesn't have anything like Rake. Yes, it has some continuous integration tools, but that are far from rake in verbosity. I've found a blog post announcing development of something called 'Pyke' - Rake for Python. The author of it is a real Python fan and the only reason to develop this 'Pyke' for him is to prove that Python is better than Ruby. The latest post about this tool is dated December 11, 2007 that means we're not going to see anything of Rake level in Python world. What a pity :(

Really I like Ruby more, but... But as was stated in my recent post I'm a bit disappointed with Ruby. That's why and only why I'm going to study Python 3.0 and see what it can offer for a Ruby fan.

Monday 1 December 2008

Microsoft Natural Ergonomic Keyboard 4000

Yes! I've got it! Hurray!

So, now I'm thinking about my second step towards ergonomic workplace. Will it be new mouse, trackball or something else?

Domain Driven Design in the essence

Here goes a small article on the essence of DDD. Being short - dive into the domain, be a part of it. Do not mess with implementation details, think higher. Understand the domain as much as you can.