Skip to content
karaaie edited this page Sep 16, 2014 · 2 revisions

Example rakefile (see spec/test_appspecs/corp.service in albacore source).

require 'bundler/setup'
require 'albacore'

Configuration = ENV['CONFIGURATION'] || 'Release'

desc 'build example project'
build :compile do |b|
  b.sln = 'corp.service.svc.sln'
  b.prop 'Configuration', Configuration
end

desc 'build service packages from all the appspecs'
appspecs :services => :compile do |as|
  as.files = Dir.glob 'svc.web/.appspec', File::FNM_DOTMATCH
  as.out   = 'build'
end

task :default => :services

This example Rakefile will create RPMs on RHEL-derivative systems, DEBs on Debian-derivative systems and Chocolatey packages on Windows, as well as publish those packages to the CI server.

As usual you can use Albacore.subscribe to jack into the output of this task-type, if you e.g. want to publish your packages to your package server - DAB or YUM. If you include the TeamCity extension, your TeamCity server will automatically become a chocolatey package server that you can use puppet-chocolatey to install the packages of on your Windows boxen. Or you can use puppet proper with a yum repo on your linux boxen.

The appspec simply looks something like this:

---
version: 1.2.3
authors: Henrik Feldt

You can put any nuget-spec property there in snake_case and it will be set in the resulting nuget file. When building RPMs, the title of the project file will be used as the id (the non-lowercased title will be used for the NuGet).

This task-type works by checking if it's running on Windows, and then running chocolatey, otherwise running fpm. This means that you have to have either installed, depending on your OS of choice.

Known .appspec options

project_path - if you are, say, building a package from a web site (like CSharpWeb is an example of), then you probably don't want to package all of your .cs files, nor would you like to package only the bin folder. Instead you add the .appspec to the list of files in the csproj file, so that it gets copied when you have a local publish like this:

build :pkg_web do |b|
  b.file = 'CSharpWeb/CSharpWeb.csproj'
  b.prop 'DeployOnBuild',  'true'
  b.prop 'PublishProfile', 'local'
  b.prop 'Configuration',  Configuration
end

After calling this task, you'll find the appspec at CSharpWeb/build/.appspec (which mean it's part of the contents of the site). Now it's easy for albacore to find it and create a package from it, but it can't easily find the project that corresponds to it, because it's not next to the csproj file.

This is where project_path comes in; make it something like CSharpWeb.csproj in the .appspec file and then albacore knows where to get the data from. The project file is relative to where the appspec is.

provider - defaults or iis_site -- needs to be specified currently if you're building a site -- a nice PR would be to discover that from the project type.

deploy_dir - fully qualified path to deploy the contents

Example IIS Site .appspec file

---
authors: Intelliplan Employees
provider: iis_site
project_path: CMDB.Web.csproj
Clone this wiki locally