cbilson / machine.specifications forked from machine/machine.specifications

This URL has Read+Write access

machine.specifications / rakefile
100644 73 lines (59 sloc) 1.835 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require 'rake'
require 'rake/testtask'
require 'pathname'
require 'rubygems'
require 'fileutils'
include FileUtils
 
class String
  def slash(path)
    if self =~ /\/$/
      return self + path
    end
 
    return self + '/' + path
  end
end
 
version = 'v3.5'
compileTarget = ENV.include?('target') ? ENV['target'] : 'debug'
project = "Machine.Specifications"
frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', version)
msbuild = File.join(frameworkDir, 'msbuild.exe')
 
task :setup => [ "setup:all" ]
 
file ".setup-done" => [ "rakefile" ] do
  Rake::Task["setup:all"].invoke
end
 
namespace :setup do
  task :all do
    touch ".setup-done"
  end
end
 
desc "Build and run specs"
task :default => [ "build", "specs:run" ]
 
desc "Build"
task :build => [ ".setup-done" ] do
  sh "#{msbuild} Source/#{project}.sln /property:Configuration=#{compileTarget}"
end
 
namespace :specs do
  task :view => :run do
    system "start Specs/#{project}.Specs.html"
  end
 
  task :run do
    puts 'Running Specs...'
    specs = ["Machine.Specifications.Specs.dll", "Machine.Specifications.Reporting.Specs.dll", "Machine.Specifications.ConsoleRunner.Specs.dll"].map {|spec| "Build/#{compileTarget}/Tests/#{spec}"}
    sh "Build/#{compileTarget}/Machine.Specifications.ConsoleRunner.exe", "--html", "Specs/#{project}.Specs.html", "-x", "example", *specs
    puts "Wrote specs to Specs/#{project}.Specs.html, run 'rake specs:view' to see them"
  end
end
 
desc "Open solution in VS"
task :sln do
  Thread.new do
    system "devenv Source/#{project}.sln"
  end
end
 
desc "Rebuild"
task :rebuild => [ ".setup-done" ] do
  sh "#{msbuild} Source/#{project}.sln /t:Rebuild /property:Configuration=#{compileTarget}"
end
 
desc "Clean"
task :clean do
  sh "#{msbuild} Source/#{project}.sln /t:Clean /property:Configuration=#{compileTarget}"
end