forked from machine/machine.specifications
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrakefile.rb
More file actions
145 lines (122 loc) · 4.15 KB
/
Copy pathrakefile.rb
File metadata and controls
145 lines (122 loc) · 4.15 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
require 'rake'
require 'fileutils'
require 'configatron'
Dir.glob(File.join(File.dirname(__FILE__), 'tools/Rake/*.rb')).each do |f|
require f
end
include FileUtils
project = "Machine.Specifications"
mspec_options = []
task :configure do
version = ENV.include?('version') ? ENV['version'].to_sym : :net_35
target = ENV.include?('target') ? ENV['target'] : 'Debug'
build_config = {
:net_35 => {
:friendly_name => 'net-3.5',
:version => 'v3.5',
:project => project,
:solution => project,
:target => target,
:compile_target => target,
:out_dir => "Build/#{target}/",
:package_name => "Distribution/#{project}-net-3.5-#{target}.zip",
:nunit_framework => "net-3.5"
},
:net_40 => {
:friendly_name => 'net-4.0',
:version => 'v4\Full',
:project => project,
:solution => "#{project}-2010",
:target => target,
:compile_target => "#{target} .NET 4.0".escape,
:out_dir => "Build/#{target}/",
:package_name => "Distribution/#{project}-net-4.0-#{target}.zip",
:nunit_framework => "net-3.5",
:exclude_from_package => "InstallResharperRunner.4*.*",
:additional_specs => ["Machine.Specifications.Example.Clr4.dll"],
}
}
configatron.configure_from_hash build_config[version]
configatron.protect_all!
puts configatron.inspect
end
Rake::Task["configure"].invoke
desc "Build and run specs"
task :default => [ "build", "tests:run", "specs:run" ]
desc "Clean"
task :clean do
MSBuild.compile \
:project => "Source/#{configatron.solution}.sln",
:version => configatron.version,
:properties => {
:Configuration => configatron.compile_target
},
:switches => {
:target => 'Clean'
}
rm_f configatron.package_name
rm_rf "Build"
end
desc "Build"
task :build do
MSBuild.compile \
:project => "Source/#{configatron.solution}.sln",
:version => configatron.version,
:properties => {
:Configuration => configatron.compile_target
}
end
desc "Rebuild"
task :rebuild => [ :clean, :build ]
namespace :specs do
task :view => :run do
system "start Specs/#{configatron.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","Machine.Specifications.DevelopWithPassion.Specs.dll"]
specs = specs | configatron.additional_specs if configatron.exists?(:additional_specs)
specs.map! {|spec| "#{configatron.out_dir}/Tests/#{spec}"}
sh "#{configatron.out_dir}/mspec.exe", "--html", "Specs/#{configatron.project}.Specs.html", "-x", "example", *(mspec_options + specs)
puts "Wrote specs to Specs/#{configatron.project}.Specs.html, run 'rake specs:view' to see them"
end
end
namespace :tests do
task :run do
puts 'Running NUnit tests...'
tests = ["Machine.Specifications.Tests.dll"].map {|test| "#{configatron.out_dir}/Tests/#{test}"}
runner = NUnitRunner.new :platform => 'x86', :results => "Specs", :clr_version => configatron.nunit_framework
runner.executeTests tests
end
end
desc "Open solution in VS"
task :sln do
Thread.new do
system "devenv Source/#{configatron.solution}.sln"
end
end
desc "Packages the build artifacts"
task :package => [ "rebuild", "tests:run", "specs:run" ] do
rm_f configatron.package_name
cp 'License.txt', configatron.out_dir
cp_r 'Distribution/Specifications/.', configatron.out_dir
sz = SevenZip.new \
:tool => 'Tools/7-Zip/7za.exe',
:zip_name => configatron.package_name
files = FileList.new('**/*') \
.exclude('*.InstallLog') \
.exclude('*.InstallState') \
.exclude('Generation') \
.exclude('Tests') \
files.exclude(configatron.exclude_from_package) if configatron.exists?(:exclude_from_package)
Dir.chdir(configatron.out_dir) do
sz.zip :files => files
end
end
desc "TeamCity build"
task :teamcity => [ :teamcity_environment, :package ]
desc "Sets up the TeamCity environment"
task :teamcity_environment do
mspec_options.push "--teamcity"
end
require "rakefile.#{configatron.friendly_name}.rb" if File.exists? "rakefile.#{configatron.friendly_name}.rb"