Friday, January 17, 2014

Using rake with Visual Studio 2010 or using rake tasks with parameters

I like ruby and I like rake to build my stuff.
Since most of the time I am coding C# with Visual Studio I wanted to use rake from within Visual Studio. You can add external tools to Visual Studio (Tools\External Tools …) but it is not possible to call rake directly with this feature.
So I wrote a small batch file which starts rake:

call rake –f C:\Tools\scripts\myrakefile.rb build[%1]

I added this batch file as External tool with the full path to the Project File that is currently selected in the Explorer View as an argument (dont't forget to check "Use Output window"):

How does this work?

The batch file calls rake and executes the build task in the rakefile. This task expects the project file it should build as parameter.
Here is the content of the rakefile:

msbuild = "C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe"
desc "Build .proj with MSBuild"
task :build, :project do |t, args| 
 # get the projectfile path from the arguments
 projectFile = args[:project]
 puts "Building #{projectFile}"
 output = `#{msbuild} #{projectFile} /t:rebuild /p:Configuration=DevEnvDebug`
 puts output  
 if output.include?("Build FAILED.")
  puts " "
  puts "***** There are Build errors! *****"

So far you can select a project file in the solution explorer and the Select the new entry in the Tools menu “Build with rake” and you will see the output from the rake script in the output window. That is not very convenient.
So let’s assign a keyboard shortcut to our external tool:

Open “Tools\Options…” and select “Environment\Keyboard”. Type “Tools.External” in the “Show commands containing:” Now you see a bunch of entries like “Tools.ExternalCommand1”, “Tools.ExternalCommand2” and so on. Since in my case the batch file I added earlier as external tool is on the eighth position, I choose “Tools.ExternalCommand8” in the list. Now you can assign a shortcut for this command. I choose Alt + B, Alt + R. Don’t forget to press the Assign button.

Now you can simply select a Project in the Solution Explorer and press Alt + B, Alt + R and you can see the rake output in the output window.
If you want to call other rake tasks from within the build task which also expect some parameters just call it like this:

#assume there is a task called othertask which takes a parameter


Wednesday, January 15, 2014

Neal Ford on Agile Engineering Practices, by Neal Ford, O'Reilly Media

Neal is Director, Software Architect and Meme Wrangler at ThoughtWorks. He has a degree in Computer Science from Georgia State University specializing in languages and compilers and a minor in mathematics specializing in statistical analysis. He is the author of several books.

Most available sources about Agile Software Development won't mention software development (engineering practice) that much. Mostly the available Books talk about the Agile process itself. This Video fills this gap since it is mainly about the engineering practice for Agile development. Neal tries to explain why those practices works so that developers can better understand them.

During the Workshop Neal talks about the following topics and explains why these are important for Agile Software Development:

  • metrics,
  • (short) feedback loops, (like TDD)
  • Automation,
  • time and space (where space means the code)
  • communication,
  • counter-intuitive, (none intuitivity),
  • demonstration trumps discussion

This Video covers the most important topics in an Agile process form the developer point of view.
He starts with the estimation process in Agile Software Development and explains how estimation in an Agile Team works and what is different compared to e. g. the Waterfall process. He explains Test Driven Development (TDD) and Testing (integration testing) in general, starting from the simple basics of TDD up to Test Driven Design and Agile Design. Neil explains parts of the SOLID (Single responsibility, Open-closed, Liskov substitution, Interface Segregation, Dependency inversion) and DRY (Don't Repeat Yourself) design principles and shows small examples for these principles and why these design principles are important. He shows why automation (including Continuous Integration and Continuous Deployment) is important in an Agile process and what developers could and should automate. And of course he talks about the benefits of Pair Programming and why it won't slow down the productivity of an Agile Team.

If you are new to Agile Software Development this Video is a perfect starting point to Agile Software Development. Even if you are working in a Company that uses Agile Processes (like SCRUM) I think you can get some new ideas on some topics. Most of the source code examples in the Video are in Java but they aren't really language dependent.

You can find more information here.