📜 ⬆️ ⬇️

Rake + Albacore. Building a .Net project using Ruby

When it comes to building .Net projects, the first thing that comes to mind is the MSBuild + utility accompanying build scripts. Indeed, while the project is small, its capabilities are quite enough. But over time, the amount of code increases, the structure of the product becomes more complex and confusing, and you begin to think about finding a more flexible solution.

In our case, this solution was a bunch of Rake + Albacore. What is it? Rake is a tool for automating the assembly of program code written in Ruby. About Rake on Habré has already been a fairly detailed article by user Lass_ua (for which, by the way, he thanks a lot), so I will not repeat. I can only say that we chose it for its exceptional flexibility, which we could not get from MSBuild scripts. It is due to the fact that the entire assembly process is described, in fact, by a Ruby program, which opens up a sea of ​​possibilities.
But about Albacore, to my surprise, I did not find a single article, although this is already a fairly mature and well-known project.

What is Albacore?

In fact, Albacore is just a set of custom tasks for Rake, focused on building .Net projects. Here is their complete list:

Installation and use

Install Rake and Albacore:
gem install rake 

 gem install albacore 

To use Albacore, just connect the appropriate module in your rakefile
 require 'albacore' 

Now we can, in addition to Rake tasks, also use Albacore tasks. In our case, the two most used of them are MSBuild (actually, the MSBuild.exe call with specified parameters) and Exec (Execution of an arbitrary command in the Windows command environment)

Call MSBuild:
  msbuild :build_solution do |msb| msb.properties = { :configuration => :Debug } msb.targets = [ :Clean, :Build ] msb.solution = "path/to/your/solution.sln" end 

The only required field here is solution. Detailed instructions for using this task can be found here.
')
For Exec, you need to define only two fields - the command itself and its parameters
  exec do |cmd| cmd.command = "LIB\\sgen\\sgen.exe" cmd.parameters = "BIN\\mylovely.dll /force" end 


Unfortunately, the Albacore task list still does not cover all the needs that may arise during the assembly of the .Net project. In our project, Gallio is used for testing, which is not in this list. But, as it turned out, the Ruby community took care of people like us, and the very first link for the query “gallio rake” led me to github: gist with the code of the corresponding task.

Impressions

The transition to a bunch of Rake + Albacore we have turned out very fast and painless, and we got the flexibility we need to build the project. Ruby is a new language for me, and I am pleasantly surprised by the amount of information and various useful pieces of code that is present on the Internet, as well as the convenience and capabilities of the language itself. I think that my acquaintance with him will not be limited to this; I plan to continue using it in our project for small related utilities.

Source: https://habr.com/ru/post/148545/


All Articles