forked from Chillisoft/habanero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile.rb
283 lines (244 loc) · 11.6 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
require 'rake'
require 'albacore'
#______________________________________________________________________________
#---------------------------------SETTINGS-------------------------------------
# set up the build script folder so we can pull in shared rake scripts.
# This should be the same for most projects, but if your project is a level
# deeper in the repo you will need to add another ..
bs = File.dirname(__FILE__)
bs = File.join(bs, "/rake-tasks")
$buildscriptpath = File.expand_path(bs)
$:.unshift($buildscriptpath) unless
$:.include?(bs) || $:.include?($buildscriptpath)
$binaries_baselocation = "bin"
$nuget_baselocation = "nugetArtifacts"
$app_version ='9.9.9.999'
#------------------------build settings--------------------------
require 'rake-settings.rb'
msbuild_settings = {
:properties => {:configuration => :debug},
:targets => [:clean, :rebuild],
:verbosity => :quiet,
#:use => :net35 ;uncomment to use .net 3.5 - default is 4.0
}
#------------------------dependency settings---------------------
#------------------------project settings------------------------
$solution = 'source/Habanero.sln'
$solutionNuget = '"source/Habanero.sln"'
$major_version = ''
$minor_version = ''
$patch_version = ''
$nuget_apikey = ''
$nuget_sourceurl = ''
$nuget_publish_version = 'Trunk'
#______________________________________________________________________________
#---------------------------------TASKS----------------------------------------
desc "Runs the build task"
task :default, [:major, :minor, :patch] => [:updatesubmodules, :setupvars, :build_test]
desc "Runs the build task and pushes to local"
task :build_push, [:major, :minor, :patch, :apikey, :sourceurl] => [:updatesubmodules, :setupvars, :build_test, :nugetpush]
desc "Runs the build task and pushes to local"
task :build_push_nobuild, [:major, :minor, :patch, :apikey, :sourceurl] => [:setupvars, :nugetpush]
desc "Builds Habanero, including tests"
task :build_test => [:build_only, :test]
desc "Builds Habanero"
task :build_only, [:major, :minor, :patch, :apikey, :sourceurl] => [:updatesubmodules,:restorepackages,:clean, :set_assembly_version, :msbuild, :copy_to_nuget]
desc "Builds Habanero, including running tests with dotcover then pushes to the local nuget server"
task :build_with_coverage, [:major, :minor, :patch, :apikey, :sourceurl] => [:build_only, :test_with_coverage]
desc "Build with sonar (stats build)"
task :build_with_sonar, [:major, :minor, :patch, :apikey, :sourceurl] => [:build_only, :sonar]
desc "Setup Variables"
task :setupvars,:major ,:minor,:patch, :apikey, :sourceurl do |t, args|
puts cyan("Setup Variables")
args.with_defaults(:major => "0")
args.with_defaults(:minor => "0")
args.with_defaults(:patch => "0000")
args.with_defaults(:apikey => "")
args.with_defaults(:sourceurl => "")
$major_version = "#{args[:major]}"
$minor_version = "#{args[:minor]}"
$patch_version = "#{args[:patch]}"
$nuget_apikey = "#{args[:apikey]}"
$nuget_sourceurl = "#{args[:sourceurl]}"
$app_version = "#{$major_version}.#{$minor_version}.#{$patch_version}.0"
puts cyan("Assembly Version #{$app_version}")
puts cyan("Nuget key: #{$nuget_apikey} for: #{$nuget_sourceurl}")
end
desc "Restore Nuget Packages"
task :restorepackages do
system 'lib\nuget.exe restore #{$solutionNuget}'
end
desc "Update Submodules"
task :updatesubmodules do
puts cyan("Updating Git Submodules")
system 'git submodule foreach git checkout master'
system 'git submodule foreach git pull'
end
#------------------------build habanero --------------------
desc "Cleans build folders"
task :clean do
puts cyan("Cleaning build folders")
FileUtils.rm_rf $binaries_baselocation
FileSystem.ensure_dir_exists "#{$binaries_baselocation}/Debug"
FileSystem.ensure_dir_exists "#{$binaries_baselocation}/Release"
FileUtils.rm_rf $nuget_baselocation
FileSystem.ensure_dir_exists $nuget_baselocation
end
task :set_assembly_version do
puts green("Setting Shared AssemblyVersion to: #{$app_version}")
file_path = "source/Common/AssemblyInfoShared.cs"
outdata = File.open(file_path).read.gsub(/"9.9.9.999"/, "\"#{$app_version}\"")
File.open(file_path, 'w') do |out|
out << outdata
end
end
desc "Builds the solution with msbuild"
msbuild :msbuild do |msb|
puts cyan("Building #{$solution} with msbuild")
msb.update_attributes msbuild_settings
msb.solution = $solution
end
desc "Runs the tests"
nunit :test do |nunit|
puts cyan("Running tests")
nunit.assemblies testassemblies
end
def testassemblies
['bin\Habanero.Test.dll',
'bin\Habanero.Test.Bo.dll',
'bin\Habanero.Test.Db.dll']
end
desc "Runs the tests with dotcover"
dotcover :test_with_coverage do |dc|
puts cyan("Running tests with dotcover")
dc.assemblies testassemblies
dc.filters '+:module=*;class=*;function=*'
end
def nugetassemblieswithpdb
["#{$binaries_baselocation}/#{$build_configuration}\Habanero.Base.dll",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.BO.dll",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.Console.dll",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.Test.dll",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.Test.BO.dll",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.Test.Structure.dll",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.Test.DB.dll",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.DB.dll",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.Base.pdb",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.BO.pdb",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.Console.pdb",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.Test.pdb",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.Test.BO.pdb",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.Test.Structure.pdb",
"#{$binaries_baselocation}/#{$build_configuration}\Habanero.Test.DB.pdb",]
end
def copy_nuget_files_to location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.Base.dll", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.BO.dll", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.Console.dll", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.Test.dll", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.Test.BO.dll", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.Test.Structure.dll", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.Test.DB.dll", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.DB.dll", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.Base.pdb", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.BO.pdb", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.Console.pdb", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.Test.pdb", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.Test.BO.pdb", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.Test.Structure.pdb", location
FileUtils.cp "#{$binaries_baselocation}/#{$build_configuration}/Habanero.Test.DB.pdb", location
end
task :copy_to_nuget do
puts cyan("Copying files to the nuget folder")
copy_nuget_files_to $nuget_baselocation
end
#------------------------------------------Build Stats------------------------------------------------------------
desc "Runs sonar"
exec :sonar do |cmd|
puts cyan("Running Sonar")
cmd.command = "cmd.exe"
cmd.parameters = "/c #{$sonar_runner_path}"
end
#------------------------------------------Single Dlls, Nuget Package Push For Internal Use------------------------------------------------------------
desc "Pushes Habanero into the given nuget folder"
task :nugetpush => [:publishBaseNugetPackage,
:publishConsoleNugetPackage,
:publishDBNugetPackage,
:publishBONugetPackage,
:publishTestNugetPackage,
:publishTestBONugetPackage,
:publishTestStructureNugetPackage,
:publishTestDBNugetPackage]
desc "Publish the Habanero.Base nuget package"
pushnugetpackagesonline :publishBaseNugetPackage do |package|
puts cyan("Habanero.Base.#{$nuget_publish_version} ,Version: #{$app_version} ,ApiKey: #{$nuget_apikey},Url: #{$nuget_sourceurl} ")
package.InputFileWithPath = "bin/Habanero.Base.dll"
package.Nugetid = "Habanero.Base.#{$nuget_publish_version}"
package.Version = $app_version
package.Description = "Habanero.Base"
package.ApiKey = "#{$nuget_apikey}"
package.SourceUrl = "#{$nuget_sourceurl}"
end
desc "Publish the Habanero.BO nuget package"
pushnugetpackagesonline :publishBONugetPackage do |package|
package.InputFileWithPath = "bin/Habanero.BO.dll"
package.Nugetid = "Habanero.BO.#{$nuget_publish_version}"
package.Version = $app_version
package.Description = "Habanero.BO"
package.ApiKey = "#{$nuget_apikey}"
package.SourceUrl = "#{$nuget_sourceurl}"
end
desc "Publish the Habanero.Console nuget package"
pushnugetpackagesonline :publishConsoleNugetPackage do |package|
package.InputFileWithPath = "bin/Habanero.Console.dll"
package.Nugetid = "Habanero.Console.#{$nuget_publish_version}"
package.Version = $app_version
package.Description = "Habanero.Console"
package.ApiKey = "#{$nuget_apikey}"
package.SourceUrl = "#{$nuget_sourceurl}"
end
desc "Publish the Habanero.DB nuget package"
pushnugetpackagesonline :publishDBNugetPackage do |package|
package.InputFileWithPath = "bin/Habanero.DB.dll"
package.Nugetid = "Habanero.DB.#{$nuget_publish_version}"
package.Version = $app_version
package.Description = "Habanero.DB"
package.ApiKey = "#{$nuget_apikey}"
package.SourceUrl = "#{$nuget_sourceurl}"
end
desc "Publish the Habanero.Test nuget package"
pushnugetpackagesonline :publishTestNugetPackage do |package|
package.InputFileWithPath = "bin/Habanero.Test.dll"
package.Nugetid = "Habanero.Test.#{$nuget_publish_version}"
package.Version = $app_version
package.Description = "Habanero.Test"
package.ApiKey = "#{$nuget_apikey}"
package.SourceUrl = "#{$nuget_sourceurl}"
end
desc "Publish the Habanero.Test.BO nuget package"
pushnugetpackagesonline :publishTestBONugetPackage do |package|
package.InputFileWithPath = "bin/Habanero.Test.BO.dll"
package.Nugetid = "Habanero.Test.BO.#{$nuget_publish_version}"
package.Version = $app_version
package.Description = "Habanero.Test.BO"
package.ApiKey = "#{$nuget_apikey}"
package.SourceUrl = "#{$nuget_sourceurl}"
end
desc "Publish the Habanero.Test.Structure nuget package"
pushnugetpackagesonline :publishTestStructureNugetPackage do |package|
package.InputFileWithPath = "bin/Habanero.Test.Structure.dll"
package.Nugetid = "Habanero.Test.Structure.#{$nuget_publish_version}"
package.Version = $app_version
package.Description = "Habanero.Test.Structure"
package.ApiKey = "#{$nuget_apikey}"
package.SourceUrl = "#{$nuget_sourceurl}"
end
desc "Publish the Habanero.Test.DB nuget package"
pushnugetpackagesonline :publishTestDBNugetPackage do |package|
package.InputFileWithPath = "bin/Habanero.Test.DB.dll"
package.Nugetid = "Habanero.Test.DB.#{$nuget_publish_version}"
package.Version = $app_version
package.Description = "Habanero.Test.DB"
package.ApiKey = "#{$nuget_apikey}"
package.SourceUrl = "#{$nuget_sourceurl}"
end