forked from timscott/catnap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rakefile.rb
122 lines (110 loc) · 4.21 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
require 'rake'
require 'albacore'
require 'fileutils'
PRODUCT_NAME = "Catnap"
BASE_PATH = File.expand_path ""
SOURCE_PATH = "#{BASE_PATH}/src"
OUTPUT_PATH = "#{BASE_PATH}/output"
UNIT_TESTS_PATH = "#{SOURCE_PATH}/#{PRODUCT_NAME}.UnitTests"
INTEGRATION_TESTS_PATH = "#{SOURCE_PATH}/#{PRODUCT_NAME}.IntegrationTests"
CONNECTIONS_DEFAULT_PATH = "#{INTEGRATION_TESTS_PATH}/default.connections.config"
CONNECTIONS_PATH = "#{INTEGRATION_TESTS_PATH}/connections.config"
UNIT_TESTS_OUTPUT_PATH = "#{OUTPUT_PATH}/unit_tests"
PACKAGE_OUTPUT_PATH = "#{OUTPUT_PATH}/package/"
PACKAGE_OUTPUT_LIB_PATH = "#{PACKAGE_OUTPUT_PATH}/lib"
INTEGRATION_TESTS_OUTPUT_PATH = "#{OUTPUT_PATH}/integration_tests"
TEST_REPORT_PATH = "#{OUTPUT_PATH}/report"
COMMON_ASSEMBY_INFO_FILE = "#{SOURCE_PATH}/CommonAssemblyInfo.cs"
VERSION = "0.1.0.0"
PACKAGE_PATH = "#{BASE_PATH}/package"
NUSPEC_FILENAME = "#{PRODUCT_NAME}.nuspec"
NUSPEC_PATH = "#{PACKAGE_PATH}/#{NUSPEC_FILENAME}"
task :default => [:standard]
task :standard => [:assemblyInfo,:config,:build,:output,:test,:define_package]
task :package => [:standard,:create_package]
msbuild :build do |msb|
msb.properties :configuration => :Release
msb.targets :Clean, :Build
msb.verbosity = "minimal"
msb.solution = "#{SOURCE_PATH}/#{PRODUCT_NAME}.sln"
end
task :output do
FileUtils.rmtree OUTPUT_PATH
FileUtils.mkdir OUTPUT_PATH
FileUtils.mkdir TEST_REPORT_PATH
FileUtils.mkdir UNIT_TESTS_OUTPUT_PATH
FileUtils.mkdir INTEGRATION_TESTS_OUTPUT_PATH
FileUtils.mkdir PACKAGE_OUTPUT_PATH
FileUtils.mkdir PACKAGE_OUTPUT_LIB_PATH
FileUtils.rmtree PACKAGE_PATH
FileUtils.mkdir PACKAGE_PATH
FileUtils.cp_r "#{UNIT_TESTS_PATH}/bin/Release/.", UNIT_TESTS_OUTPUT_PATH
FileUtils.cp_r "#{INTEGRATION_TESTS_PATH}/bin/Release/.", INTEGRATION_TESTS_OUTPUT_PATH
copy_files UNIT_TESTS_PATH, PACKAGE_OUTPUT_LIB_PATH, PRODUCT_NAME, ["dll", "pdb", "xml"]
end
mspec :test do |mspec|
mspec.command = "#{SOURCE_PATH}/packages/Machine.Specifications.0.4.13.0/tools/mspec-x86.exe"
mspec.assemblies = "#{UNIT_TESTS_OUTPUT_PATH}/#{PRODUCT_NAME}.UnitTests.dll", "#{INTEGRATION_TESTS_OUTPUT_PATH}/#{PRODUCT_NAME}.IntegrationTests.dll"
mspec.html_output = TEST_REPORT_PATH
end
desc "Assembly Version Info Generator"
assemblyinfo :assemblyInfo do |asm|
FileUtils.rm COMMON_ASSEMBY_INFO_FILE, :force => true
asm.output_file = COMMON_ASSEMBY_INFO_FILE
asm.title = PRODUCT_NAME
asm.company_name = "Lunaverse Software"
asm.product_name = PRODUCT_NAME
asm.version = VERSION
asm.file_version = VERSION
asm.copyright = "Copyright (c) 2011 Lunaverse Software"
end
task :config do
if !File.exists? CONNECTIONS_PATH
FileUtils.cp CONNECTIONS_DEFAULT_PATH, CONNECTIONS_PATH
end
end
desc "Create the Catnap nuspec file"
nuspec :define_package do |nuspec|
version = "#{ENV['version']}"
nuspec.id = "Catnap"
nuspec.version = version.length == 7 ? version : VERSION
nuspec.authors = "Tim Scott"
nuspec.owners = "Tim Scott"
nuspec.description = "A basic lightweight object relational mapper (ORM) for .NET."
nuspec.title = "Catnap"
nuspec.language = "en-US"
nuspec.licenseUrl = "https://github.com/timscott/catnap/blob/master/LICENSE.TXT"
nuspec.projectUrl = "https://github.com/timscott/catnap/wiki"
nuspec.tags = "ORM Sqlite Mobile MonoTouch Database ObjectRelationalMapping"
nuspec.working_directory = PACKAGE_PATH
nuspec.output_file = NUSPEC_FILENAME
end
desc "Create the nuget package"
task :create_package do
execute_nuget "pack #{NUSPEC_PATH} -basepath #{PACKAGE_OUTPUT_PATH} -outputdirectory #{PACKAGE_PATH}"
end
desc "Publish to nuget"
task :publish do
$stdout.sync = true
print "Are you sure? (Y/[N])? "
input = STDIN.gets.strip
if input.downcase == 'y'
execute_nuget "push #{PACKAGE_PATH}/#{PRODUCT_NAME}.#{VERSION}.nupkg"
end
end
def copy_files(from, to, filename, extensions)
extensions.each do |ext|
from_name = "#{from}#{filename}.#{ext}"
to_name = "#{to}#{filename}.#{ext}"
if File.exists? from_name
puts "Copying '#{from_name}' to '#{to_name}'"
FileUtils.cp from_name, to_name
end
end
end
def execute_nuget(parameters)
cmd = Exec.new
cmd.command = "tools/nuget.exe"
cmd.parameters = parameters
cmd.execute
end