Don’t forget to check out Part 1 and Part 2.
Rubicant basically has 4 main parts, as mentioned in the first part of this series. They are as follows:
The CscTask
The CscTask is used for compiling C# files. It’s usage is like:
1: CscTask.new(:task_name => :dependencies) do |csc|
2: csc.target = 'library'
3: csc.references = FileList["libs\*.dll"]
4: csc.out = "hello_world.exe"
5: csc.debug = "full"
6: csc.files = FileList["src/**/*.cs"]
7: end
target: Any target that the csc compiler takes (exe, winexe, library, etc)
references: The list of assemblies that are referenced during compilation
out: The output filename
debug: if this is set(to anything), the compiler will be passed /debug:full to create debugging information
files: The list of files to be compiled
CscTask also has a shortcut that can be accessed as follows:
1: csc(name, dependencies, opts)
2:
3: ex:
4: csc :name, [:dependencies], { :target => 'library',
5: :references = FileList["libs\*.dll"],
6: :out = "hello_world.exe",
7: :debug = "full",
8: :files = FileList["src/**/*.cs"] }
The MBUnit Helper
The MBUnit helper is used to run tests using mbunit v2. It is used as follows:
1: mbunit(mbunit_dir, test_dir, test_files, opts={})
2:
3: ex:
4: mbunit("/path/to/mbunit/dlls",
5: FileList["/test/dlls/test.dll"],
6: {:working_dir => "/dir/to/run/tests/in",
7: :assembly_path => FileList["/assemblies/to/include/*.dll"],
8: :report_folder => "sets /rf:",
9: :report_name_format => "sets /rnf:",
10: :report_type => "sets /rt:",
11: :show_reports => "sets /sr:",
12: :transform => "sets /tr:",
13: :filter_category => "sets /fc:",
14: :exclude_category => "sets /ec:",
15: :filter_author => "sets /fa:",
16: :filter_type => "sets /ft:",
17: :filter_namespace => "sets /fn:",
18: :verbose => "sets /v{optionvalue}",
19: :shadow_copy => "sets /sc:" }
For a complete listing of the mbunit command line options, please visit http://docs.mbunit.com/help/html/gettingstarted/MbUnitConsoleRunner.htm.
This runs the tests in test_files in the test_dir with the dlls from mbunit_dir using the options in opts. Currently, this will physically copy the minimum required mbunit dlls and mbunit.cons.exe to the test dir, run the tests and then remove the files.
The CopyFiles Task
The copy files task will copy files from one directory to another, while maintaining the folder structure.
1: CopyFiles.new(:name) do |cf|
2: cf.base_dir = "/some/dir"
3: cf.file_globs = ["**/somefiles/*.cs", **/otherfiles/*.cs"]
4: cf.target_dir = "/another/dir"
5: cf.excludes = ["AssemblyInfo.cs"]
6: end
base_dir: The base directory to start copying files from
file_globs: The globs of files to be copied from base_dir
target_dir: The target directory to place the files in
excludes: (Optional) list of files to be excluded from the copy.
The Expand Template File Task
Usage is:
1: expand_template(template, output_file)
This will read in the file specified by template and expand it out and write it to the location of output_file.
WARNING: I am fairly certain that the only reason this is working right now for me is because I use configatron, which is accessed as a singleton. It is entirely possible that variables declared in your build script will not be accessible during template expansion. I will be testing this in the near future, however.
Framework Selection
Currently, only the .Net 2.0 and .Net 3.5 frameworks are configured. .Net 3.5 is the selection by default. However, you can choose which framework you want to use by adding framework={framework} in the build line. For example:
1: rake deploy_local framework=net20
This will run the deploy_local task in the default rakefile using the .Net 2.0 framework.
Valid framework values are:
net20 – .Net 2.0
net35 - .Net 3.5
These frameworks are discovered using the registry, so you shouldn’t have to put in the location of your csc.exe file.
What else?
Well, that’s about all it really does right now. The rest is just built in rake and ruby goodness. I would like to add msbuild support for those that are building WPF apps. I would also like to add some nunit support, as well as some support for other things like easy creation of assemblyinfo.cs files and possibly some deployment tasks for iis7. Who knows. We’ll see how I like things and if I really take to using this (I think I will).