Albacore AssemblyInfo Task vs. Nant Assembly Info Generator

Here’s one of the reasons I like Rake and my custom Rake tasks that I’m building into Albacore, so much.

To generate some assembly information such as version, company name, copyright, etc., you need to do this with nant:

   1: <?xml version="1.0"?>

   2: <project name="Assembly Version Info Generator" default="buildVersionInfo" basedir=".">

   3:     <target name="buildVersionInfo">

   4:         <asminfo output=".SomeFolderAssemblyInfo.cs" language="CSharp">

   5:             <imports>

   6:                 <import namespace="System.Reflection" />

   7:             </imports>

   8:             <attributes>

   9:                 <attribute type="AssemblyCompanyAttribute" value="MyCompany, Inc." />

  10:                 <attribute type="AssemblyProductAttribute" value="MyProduct" />

  11:                 <attribute type="AssemblyVersionAttribute" value="0.0.0.0" />

  12:                 <attribute type="AssemblyCopyrightAttribute" value="Copyright (c)2009 MyCompany, Inc. All Rights Reserved." />

  13:             </attributes>

  14:         </asminfo>

  15:     </target>

  16: </project>

To do the same thing with Albacore, you only need this:

   1: desc "Assembly Version Info Generator"

   2: Rake::AssemblyInfoTask.new(:assemblyinfo) do |asm|

   3:     asm.output_file = "./SomeFolder/AssemblyInfo.cs"

   4:     asm.company_name = "MyCompany, Inc."

   5:     asm.product_name = "MyProduct"

   6:     asm.version = "0.0.0.0"

   7:     asm.copyright = "Copyright (c)2009 MyCompany, Inc. All Rights Reserved."

   8: end

I’ll take the half-the-size, easier-to-read lines of no angle-bracket-tax where I can write real code, any day.


Post Footer automatically generated by Add Post Footer Plugin for wordpress.

About Derick Bailey

Derick Bailey is an entrepreneur, problem solver (and creator? :P ), software developer, screecaster, writer, blogger, speaker and technology leader in central Texas (north of Austin). He runs SignalLeaf.com - the amazingly awesome podcast audio hosting service that everyone should be using, and WatchMeCode.net where he throws down the JavaScript gauntlets to get you up to speed. He has been a professional software developer since the late 90's, and has been writing code since the late 80's. Find me on twitter: @derickbailey, @mutedsolutions, @backbonejsclass Find me on the web: SignalLeaf, WatchMeCode, Kendo UI blog, MarionetteJS, My Github profile, On Google+.
This entry was posted in .NET, Albacore, Productivity, Rake, Ruby. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://www.jamesthigpen.com/ James Thigpen

    Thank you for rocking the face off of why everyone should be using Rake. I want to bake you a cookie.

    NAnt is horrible. HORRIBLE. I mean it’s genuinely bad. I can’t begin to fathom why people continue to use it. Thinking about it makes my face twitch.

    I’m recommending Albacore to every single person asking me anything about an automated build.

    Another reason for using Albacore over Nant: copying files. Every build has to copy files, but an XML syntax for copying a file is just moronic.

    Down with angle brackets!

  • http://www.lostechies.com/members/derick.bailey/default.aspx derick.bailey

    @James

    awesome

    and i’m going to hold you go that fresh baked cookie… one of these days we’ll end up meeting IRL, and you better have a cookie with you. :)

  • http://www.tobinharris.com Tobin Harris

    Awesome to see someone doing some Rake goodness. I’d be interesting in collaborating.

    Here’s a few ideas (don’t worry, just food for thought, I know some of this might be off piste right now).

    1) Add a readme.markdown file explaining the project installation, usage, purpose and vision.

    2) Make it mono compatible.

    3) Test it on IronRuby

    Look forward to watching this project :)

  • http://www.lostechies.com/members/derick.bailey/default.aspx derick.bailey

    @tobin,

    thanks for volunteering to do that markdown! :)

    seriously, though… i’ve been meaning to create one, but haven’t got around to it. you can get all the install instructions on the Albacore wiki, though:

    http://wiki.github.com/derickbailey/Albacore

    mono / ironruby: are you using these platforms? If so, i’d love to work with you on getting these support in albacore.

  • http://www.lostechies.com/members/derick.bailey/default.aspx derick.bailey

    @tobin,

    Like everything else that i tend to put off, the readme markdown was easier than i thought! especially using the e text editor and it’s markdown preview. :)

    readme has been added to the github page, to include installation instructions!

  • http://www.tobinharris.com Tobin Harris

    @derick

    Well played with the Markdown file, I think any GitHub project looks lost without one :)

    I’m using IronRuby for my own Rake stuff, and enjoying being able to write rake tasks that work with domain stuff such as NHibernate entities directly.

    Mono is a direction I’m really interested in, I don’t know why, but everything is so damned fast when I’m building/testing on Mono + OSX. I’ve really used Mono in anger yet, but hope to. I also pray that JetBrains will pull their finger out and make a cross platform IDE for .NET. This might never happen due to their comfort zone with R# :(

    Will grab your stuff next time I’m near an IronRuby Rake file. How do we do this, shall I fork?

  • http://www.lostechies.com/members/derick.bailey/default.aspx derick.bailey

    @tobin,

    You can clone it to your local box, or just install the gem and see if it works on IronRuby. If you find issues and want to fix them, or if you see the need to add options that I haven’t included on the object models (i’m only including what I need, when I need it… ), then a fork would be the best way to go about doing that.

  • http://www.tobinharris.com Tobin Harris

    Cool, will do.

  • Dara

    I need intellisense.. how the hell am i going to rememeber all these properties?

  • http://www.lostechies.com/members/derick.bailey/default.aspx derick.bailey

    @Dara,

    The cynical side of my wants to say “intellisense is a crutch”, and I do think that this is true, to an extend. But then, the honest side of me says “damn right I miss intellisense!”

    The good news is editors like e text editor, jetbrains rubymine, maybe textmate?, and probably others do offer some intellisense capabilities.

    Plus, you can always check the documentation on the wiki.