Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET 4.5
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Amazon Web Services
Analysis Services
Android
Architecture
Arduino
ASP .NET Web API
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
BDD
Big Data
Bing
BizTalk
Book Excerpts
Build and Deploy
Business Intelligence
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE Framework Info - non Technical
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Debugger
Design Patterns
Development Process
Display Technologies
Distributed Computing
Document Database
DotNetNuke
DSL
Dynamic Languages
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
HTML 5
Internet Explorer 8.0
Interviews
IOS
iPhone
Iron Ruby
Java
Java Script
JavaScript
jQuery
JSON
Lightswitch
LINQ
Linux
LUA
Mac OS X
MDX
Messaging
Metro
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
MVVM
MySQL
Network
NHibernate
node.js
NOSQL
Nuget
Object Oriented Development
Objective C
Odata
OLAP
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
PHP
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Prolog
Python
Q&A
Rails
Rake
Razor
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Scheme
Search
Security
Services
SharePoint
SignalR
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server 2012
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
TFS
Tips
TypeScript
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 11
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio 2011
Visual Studio 2012
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WebMatrix
WF
Whitepapers
Windows 7
Windows 8
Windows Azure
Windows Live
Windows Phone 7
Windows Phone SDK
Windows Server
Windows Vista
WinForms
WinRT
Workflow
WPF
XAML
Xiine Documentation
XML
XNA
XSLT



LearnNow


XAMALOT
 


SSWUG

Reader rating:
Click here to read 6 comments about this article.
Article source: CoDe (2010 May/Jun)


Article Pages:  1  2 3 4 - Next >


Building .NET Systems with Ruby, Rake and Albacore

Automated build tools have been around for a long time. Many of the early tools were simple batch scripts that made calls out to other command-line tools like compilers and linkers. As the need for more and more complexity in the build scripts was realized, specialized tools like Make were introduced. These tools offered more than just sequential processing of commands. They provided some logic and decision making as well as coordination of the various parts of the build process. Since Make was first introduced, many variations and specialized versions have been introduced for various languages and platforms. Rake - the “Ruby Make” system - may not have much more than its namesake to claim a connection to Make, but it is a build tool that is quickly growing in popularity and providing .NET developers with new options.

.NET Build Tools

From the early days and beta versions of .NET, the NAnt tool has been available and has been one of the most popular build systems in the .NET realm. MSBuild has been gaining in popularity since its first release, as well. It is now included as part of the .NET SDK and is used by Visual Studio and other build systems to automate some .NET project and solution builds. While NAnt and MSBuild are both configured through XML, other build tools have taken a code-based approach to build scripts. For example, PSake runs in Microsoft’s PowerShell, Bake uses the Boo language on the .NET platform and FAKE is bringing build automation through the F# language. Then there’s Rake

Rake natively runs in Ruby - just about every Ruby runtime that you can find, on any operating system that has a Ruby runtime, including the .NET platform through the IronRuby runtime. This helps to give Rake a very broad user base across a large number of platforms and languages. Even prior to the IronRuby runtime, though, Rake has been in use by .NET developers and has been growing in popularity. It is a powerful tool with many add-ons and options available including the Albacore project - a suite of Rake tasks that is targeted at building .NET systems.

Listing 1 shows a complete build script for a simple Web project using Ruby, the Rake build system and the Albacore suite of Rake tasks. This script will generate common assembly information to be used in the project, build the project, run all unit tests for the project, and deploy the project’s runtime files out to a folder so that it can be pushed out to a Web server.

In this article, I will show you how to get your .NET project building with Ruby, Rake and Albacore. I will also demonstrate some of the more advanced features of Albacore to help manage the configuration of your build process, generate project configuration files at build time, publish your project output, and more. The goal is to create a build script that is simple to set up, easy to read and easy to update.

Before I show you the details of Albacore and its many options, you will need both Ruby and Rake installed on your Windows-based computer. If you already have them set up and are familiar with the basic Rake task usage, you can skip to the section titled “The Albacore Project”. If you would like to know more about the basics of Rake or you just want a quick refresher, continue reading the next sections.

Installing Ruby

If you already have Ruby running on your Microsoft Windows-based computer you should not need to reinstall it. If you don’t have Ruby, you can get the RubyInstaller package from http://rubyforge.org/projects/rubyinstaller/. Grab the latest installer for Ruby v1.8 (at the time of writing, “ruby-1.8.6-p383-rc1.exe”) and run it. When you get to the screen shown in Figure 1, be sure to check the option to modify your PATH variable. Whether you select the option to associate .rb and .rbw files with this Ruby installation is up to you. This option allows you to double-click your .rb and .rbw files to run them. I’ll run all of the examples shown in this article directly from a command prompt.

Click for a larger version of this image.

Figure 1: Be sure to select the “Add Ruby executable to your PATH” option.

After you have completed the installation, open a command prompt and run “ruby --version”. You should see a response similar to that of Figure 2. This will verify that you have installed Ruby and that it has modified your PATH variable correctly.

Click for a larger version of this image.

Figure 2: Check to make sure Ruby installed correctly.

If you receive an error saying that your system does not Ruby as a command or executable, you may need to manually update your PATH variable or restart your system. Once you have Ruby running, though, you can move on to installing Rake.

&

By: Derick Bailey

Derick Bailey is a software developer, architect, and technology leader in central Texas. He has more than 12 years of professional software development experience and more than 20 years of experience writing code. Derick is a blogger with LosTechies.com and has been active in developer communities around Texas (including Austin, San Antonio and Dallas) and online.

derickbailey@gmail.com

Fast Facts


What Is Albacore?

Albacore is a suite of Rake tasks that helps build .NET systems. It includes options for executing many common tools including MSBuild, NUnit, XUnit, creating AssemblyInfo files and more.



Listing 1: A complete build script with Ruby, Rake and Albacore
require ‘albacore’

@buildnumber = ENV[“CCNetLabel”]

task :default => [:versioning:build:unittests]

assemblyinfo :versioning do |asm|
  asm.output_file = “src/assemblyinfo.cs”
  asm.version = “1.0.0.#{@buildnumber}”
  asm.company_name = “My Company, Inc.”
  asm.copyright = “Copyright (C)2010 My Company, Inc.”
end

msbuild :build do |msb|
  msb.solution = "src/example.sln"
  msb.targets :clean:build
  msb.properties :configuration => :release
end

nunit :unittests do |nunit|
  nunit.path_to_command = “nunit/nunit-console.exe”
  nunit.assemblies “src/tests/bin/release/tests.dll”
end

msbuild :publish do |msb|
  msb.targets :ResolveReferences:_CopyWebApplication
  msb.properties(
    :configuration => :release
    :webprojectoutputdir => “../publish/”,
    :outdir => “../publish/bin/”
  )
  msb.solution = “src/webapp/webproject.csproj”
end


Article Pages:  1  2 3 4 - Next Page: 'Installing Rake' >>

Page 1: Building .NET Systems with Ruby, Rake and Albacore
Page 2: Installing Rake
Page 3: Build a Solution
Page 4: Advanced Usage and Options

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
3.7 out of 5

15 people have rated this article.

Instantly Search Terabytes Of Text
“Lightning Fast”
– Redmond Mag
“Covers all data
sources” – eWeek
25+ fielded & full-text search options
dtSearch’s own document filters highlight hits in popular file types
Web Spider supports static & dynamic data
APIs for .NET, Java, C++, SQL, etc.
Win / Linux (64-bit & 32-bit)
www.dtSearch.com
 

      AppsWorld Europe

 

SSWUG