Skip to content
jhollingworth edited this page Oct 24, 2010 · 8 revisions

As part of a project I worked on we had a solution for each feature of the application which all needed to be consumed by another application. To achieve this I created to tasks, package_feature for packaging the needed feature resources and then another command for consuming those packages.

How to package a feature

Firstly you need to create a feature.yml file (just a normal yaml file) and include it in the root of each project which you want to define as a feature. You will also need to set the feature.yml’s properties to copy to the output directory.

Inside of the feature.yml file you will need to set two properties, the name (name of the feature) and the destination name (name of the application which you want to consume the feature). e.g.

name: "some_cool_feature"
destination_name: "some_feature_consumer"

Next, you will need to specify the root of the solution containing the feature using the source_dir property. You also need to specify the directory the feature package will be copied to. This is the directory the package_consumer will look in for any features. Optionally, you can also specify the file types the packager should copy (by default it will copy aspx, ascx, js, css, png, gif, jpeg and dll’s).

require 'rubygems'
require 'alabcore'
require 'seabass'

msbuild do |msb|
    msb.properties :configuration => :Debug, :outdir  => "C:\Feature"
    msb.solution = "Feature.sln"
end

package_feature do |p|
	p.source_dir = "c:\feature"
	p.package_dir = "c:\packages"
	p.valid_file_types = ["aspx", "ascx", "js" ] #optional
end

task :default => [msbuild, package_feature]

With the above example, it should copy all aspx, ascx & js files (mirroring the folder structure) in the project containing the features.yml file into “c:\packages\some_cool_feature\some_feature_consumer”

How to consume a feature

Once you have packaged a feature, the next step is to consume that feature from another application. To do this you need to run the consume_features command. The 3 parameters required are:

  • package_dir: The folder that all packages are copied into. Must be the same value as the package_dir property used in the package_feature command
  • consumer_dir: The folder of the consumer application you want to copy the feature files into.
  • application_name: The name of the consumer application. This should correspond with the destination name that is specified in each feature.yml file.
require 'rubygems'
require 'alabcore'
require 'seabass'

msbuild do |msb|
    msb.properties :configuration => :Debug, :outdir  => "c:\consumer\"
    msb.solution = "Consumer.sln"
end

consume_features do |c|
    c.package_dir = "c:\packages"
    c.consumer_dir = "c:\consumer\_PublishedWebsites\Consumer"
    c.application_name = "some_feature_consumer"
 end 
 
task :default => [msbuild, consume_features]

In the above example, it would mirror the directory structure and any files found in c:\packages\*\some_feature_consumer\ into the directory c:\consumer\_PublishedWebsites\Consumer\.

Clone this wiki locally