forked from FubuMvcArchive/storyteller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RakeFile
111 lines (88 loc) · 3.72 KB
/
RakeFile
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
COMPILE_TARGET = ENV['config'].nil? ? "release" : ENV['config']
include FileTest
require 'albacore'
load "VERSION.txt"
RESULTS_DIR = "results"
PRODUCT = "Storyteller"
COPYRIGHT = 'Copyright 2009-2011 Jeremy D. Miller, et al. All rights reserved.';
COMMON_ASSEMBLY_INFO = 'src/CommonAssemblyInfo.cs';
CLR_TOOLS_VERSION = "v4.0.30319"
buildsupportfiles = Dir["#{File.dirname(__FILE__)}/buildsupport/*.rb"]
if( ! buildsupportfiles.any? )
# no buildsupport, let's go get it for them.
sh 'git submodule update --init' unless buildsupportfiles.any?
buildsupportfiles = Dir["#{File.dirname(__FILE__)}/buildsupport/*.rb"]
end
# nope, we still don't have buildsupport. Something went wrong.
raise "Run `git submodule update --init` to populate your buildsupport folder." unless buildsupportfiles.any?
buildsupportfiles.each { |ext| load ext }
tc_build_number = ENV["BUILD_NUMBER"]
build_revision = tc_build_number || Time.new.strftime('5%H%M')
build_number = "#{BUILD_VERSION}.#{build_revision}"
BUILD_NUMBER = build_number
props = { :stage => File.expand_path("build"), :stage35 => File.expand_path("build35"), :artifacts => File.expand_path("artifacts") }
desc "**Default**, compiles and runs tests"
task :default => [:compile, :ilrepack, :unit_test]
#task :default => [:compile, :unit_test, :stage, "fx35:compile", "fx35:unit_test", "fx35:stage"]
task :ci => [:update_all_dependencies, :default, :history, :package]
desc "Update the version information for the build"
assemblyinfo :version do |asm|
asm_version = build_number
begin
commit = `git log -1 --pretty=format:%H`
rescue
commit = "git unavailable"
end
puts "##teamcity[buildNumber '#{build_number}']" unless tc_build_number.nil?
puts "Version: #{build_number}" if tc_build_number.nil?
asm.trademark = commit
asm.product_name = PRODUCT
asm.description = build_number
asm.version = asm_version
asm.file_version = build_number
asm.custom_attributes :AssemblyInformationalVersion => asm_version
asm.copyright = COPYRIGHT
asm.output_file = COMMON_ASSEMBLY_INFO
end
desc "Prepares the working directory for a new build"
task :clean => [:update_buildsupport] do
FileUtils.rm_rf props[:stage]
FileUtils.rm_rf props[:stage35]
# work around nasty latency issue where folder still exists for a short while after it is removed
waitfor { !exists?(props[:stage]) }
Dir.mkdir props[:stage]
waitfor { !exists?(props[:stage35]) }
Dir.mkdir props[:stage35]
Dir.mkdir props[:artifacts] unless exists?(props[:artifacts])
end
def waitfor(&block)
checks = 0
until block.call || checks >10
sleep 0.5
checks += 1
end
raise 'waitfor timeout expired' if checks > 10
end
desc "Compiles the app"
msbuild :compile => [:restore_if_missing, :clean, :version] do |msb|
msb.command = File.join(ENV['windir'], 'Microsoft.NET', 'Framework', CLR_TOOLS_VERSION, 'MSBuild.exe')
msb.properties :configuration => COMPILE_TARGET
msb.solution = "src/Storyteller.sln"
msb.targets :Rebuild
msb.log_level = :verbose
end
desc "Runs unit tests"
task :unit_test => :compile do
runner = NUnitRunner.new :compilemode => COMPILE_TARGET, :source => 'src', :platform => 'x86'
# don't feel like dealing w/ STA stuff this morning , 'StoryTeller.UserInterface.Testing'
runner.executeTests ['StoryTeller.Testing']
end
desc "Merge newtonsoft assembly into the main StoryTeller project"
task :ilrepack do
merge_newtonsoft("src/StoryTeller/bin/#{COMPILE_TARGET}", 'StoryTeller.dll')
end
def merge_newtonsoft(dir, assembly)
output = File.join(dir, assembly)
packer = ILRepack.new :out => output, :lib => dir
packer.merge :lib => dir, :refs => [assembly, 'Newtonsoft.Json.dll']
end