-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrakefile.rb
127 lines (101 loc) · 3.71 KB
/
rakefile.rb
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
require 'rake'
require 'rake/packagetask'
require 'build_utils.rb'
# project
PROJECT_NAME = "DbSnapshot"
PRODUCT_NAME = "DbSnapshot"
MAJOR_VERSION = "0"
MINOR_VERSION = "3"
BUILD_NUMBER = "0"
REVISION_NUMBER = "0"
COPYRIGHT = "Copyright © 2009 Dane O'Connor. All rights reserved."
# compilation
COMPILE_MODE = "release"
CLR_VERSION = "v3.5"
# paths
SOURCE_DIR = "src"
OUTPUT_DIR = "output"
PACKAGE_DIR = "output/pkg"
BIN_DIR = "output/bin"
NUNIT_EXE = "tools/NUnit/nunit-console.exe"
task :default => [:main]
task :main => [:clean, :compile, :test, :publish]
desc "Creates output directory"
directory OUTPUT_DIR
desc "Prepares the working directory for a new build"
task :clean do
clean = Rake::FileList.new
clean.include(File.join(SOURCE_DIR, '**/*.suo'))
clean.include(File.join(SOURCE_DIR, '**/*.sln.cache'))
clean.include(File.join(SOURCE_DIR, '**/*.csproj.user'))
clean.include(File.join(SOURCE_DIR, '**/obj'))
puts "Cleaning directories..."
clean.each { |fn| rm_r fn rescue nil }
puts "Clean succeeded.".green
end
desc "Restores working directory to fresh checkout state"
task :clobber => [:clean] do
clobber = Rake::FileList.new
clobber.include OUTPUT_DIR
clobber.each { |fn| rm_r fn rescue nil }
end
desc "Compiles the solution"
task :compile => [:clean, :overwrite_assembly_info] do
solutions = FileList[File.join(SOURCE_DIR, '*.sln')]
puts "compiling #{solutions.length} solutions:\r\n#{solutions.join("\r\n")}"
solutions.each do |solution_path|
MSBuildRunner.compile :compilemode => COMPILE_MODE,
:solutionfile => solution_path,
:clrversion => CLR_VERSION
end
end
desc "Runs tests with NUnit."
task :test => [:output] do
assemblies_to_test = FileList["#{SOURCE_DIR}/**/#{COMPILE_MODE}/*.Test.dll"].exclude(/obj\//)
puts "Running tests found in #{assemblies_to_test.length} assemblies:\r\n#{assemblies_to_test.join("\r\n")}"
runner = NUnitRunner.new :tool => NUNIT_EXE,
:exclude_categories => ['Performance'],
:results_file => File.join(OUTPUT_DIR, "test-results.xml")
runner.test(assemblies_to_test)
puts "Tests Successful".green
end
desc "Overwrites existing assembly info, injecting the proper context values"
task :overwrite_assembly_info do
infos = FileList["#{SOURCE_DIR}/**/AssemblyInfo.cs"]
puts "Overwriting #{infos.length} AssemblyInfo Files..."
infos.each do |path|
puts "#{path}"
File.open(path, 'w') do |f|
f.puts "// This file was generated by a rake task in rakefile.rb"
f.puts "using System.Reflection;"
f.puts "using System.Runtime.CompilerServices;"
f.puts "using System.Runtime.InteropServices;"
f.puts ""
f.puts "[assembly: AssemblyTitle(\"DbSnapshot\")]"
f.puts "[assembly: AssemblyDescription(\"\")]"
f.puts "[assembly: AssemblyConfiguration(\"\")]"
f.puts "[assembly: AssemblyCompany(\"\")]"
f.puts "[assembly: AssemblyProduct(\"#{PRODUCT_NAME}\")]"
f.puts "[assembly: AssemblyCopyright(\"\")]"
f.puts "[assembly: AssemblyCulture(\"\")]"
f.puts ""
f.puts "[assembly: ComVisible(false)]"
f.puts "[assembly: Guid(\"d8329bc3-1ee1-46e4-a762-c6f9cff93b29\")]"
f.puts ""
f.puts "[assembly: AssemblyVersion(\"#{MAJOR_VERSION}.#{MINOR_VERSION}.#{BUILD_NUMBER}.#{REVISION_NUMBER}\")]"
f.puts "[assembly: AssemblyFileVersion(\"#{MAJOR_VERSION}.#{MINOR_VERSION}.#{BUILD_NUMBER}.#{REVISION_NUMBER}\")]"
end
end
end
desc "Publishes the main library's compiled binaries to #{BIN_DIR}"
task :publish => [:test, :output] do
puts 'Publishing...'
FileUtils.cp_r(File.join(SOURCE_DIR, '/DbSnapshot/bin/Release/'), BIN_DIR)
FileUtils.cp('License.txt', BIN_DIR)
puts 'Publish Successful'.green
end
Rake::PackageTask.new(PROJECT_NAME, VERSION) do |p|
p.need_zip = true
p.package_files.include("output/bin/*")
p.package_dir = PACKAGE_DIR
end