rake-dotnet 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/History.txt +22 -0
  2. data/Manifest.txt +39 -1
  3. data/Rakefile.rb +44 -14
  4. data/coverage/index.html +576 -0
  5. data/coverage/lib-assemblyinfo_rb.html +716 -0
  6. data/coverage/lib-bcpcmd_rb.html +704 -0
  7. data/coverage/lib-cli_rb.html +646 -0
  8. data/coverage/lib-fxcop_rb.html +723 -0
  9. data/coverage/lib-harvester_rb.html +741 -0
  10. data/coverage/lib-iisappcmd_rb.html +657 -0
  11. data/coverage/lib-msbuild_rb.html +713 -0
  12. data/coverage/lib-ncover_rb.html +773 -0
  13. data/coverage/lib-package_rb.html +691 -0
  14. data/coverage/lib-sevenzip_rb.html +665 -0
  15. data/coverage/lib-sqlcmd_rb.html +680 -0
  16. data/coverage/lib-svn_rb.html +671 -0
  17. data/coverage/lib-version_rb.html +651 -0
  18. data/coverage/lib-xunit_rb.html +727 -0
  19. data/doc/examples.html +482 -0
  20. data/lib/rake_dotnet.rb +826 -616
  21. data/lib/rake_dotnet/default_rakefile.rb +16 -0
  22. data/spec/assemblyinfotask_spec.rb +8 -0
  23. data/spec/bcpcmd_spec.rb +81 -0
  24. data/spec/cli_spec.rb +48 -0
  25. data/spec/constants_spec.rb +6 -0
  26. data/spec/fxcopcmd_spec.rb +8 -0
  27. data/spec/fxcoptask_spec.rb +7 -0
  28. data/spec/harvester_spec.rb +6 -0
  29. data/spec/harvestoutputtask_spec.rb +6 -0
  30. data/spec/harvestwebapplicationtask_spec.rb +6 -0
  31. data/spec/iisappcmd_spec.rb +15 -0
  32. data/spec/msbuildcmd_spec.rb +7 -0
  33. data/spec/msbuildtask_spec.rb +7 -0
  34. data/spec/ncoverconsolecmd_spec.rb +12 -0
  35. data/spec/ncoverreportingcmd_spec.rb +14 -0
  36. data/spec/ncovertask_spec.rb +24 -0
  37. data/spec/rdnpackagetask_spec.rb +6 -0
  38. data/spec/sevenzipcmd_spec.rb +7 -0
  39. data/spec/sqlcmd_spec.rb +52 -0
  40. data/spec/svncmd_spec.rb +45 -0
  41. data/spec/versioner_spec.rb +6 -0
  42. data/spec/xunitcmd_spec.rb +10 -0
  43. data/spec/xunittask_spec.rb +7 -0
  44. metadata +77 -9
  45. data/test/test_rake_dotnet.rb +0 -16
data/lib/rake_dotnet.rb CHANGED
@@ -35,34 +35,36 @@ require 'rake/tasklib'
35
35
  require 'rake/clean'
36
36
  require 'pathname'
37
37
 
38
-
39
38
  desc "Displays this message; a list of tasks"
40
39
  task :help do
41
- taskHash = Hash[*(`rake.cmd -T`.split(/\n/).collect { |l| l.match(/rake (\S+)\s+\#\s(.+)/).to_a }.collect { |l| [l[1], l[2]] }).flatten]
42
-
43
- indent = " "
44
-
45
- puts "rake #{indent}#Runs the 'default' task"
46
-
47
- taskHash.each_pair do |key, value|
48
- if key.nil?
49
- next
50
- end
51
- puts "rake #{key}#{indent.slice(0, indent.length - key.length)}##{value}"
52
- end
40
+ taskHash = Hash[*(`rake.cmd -T`.split(/\n/).collect { |l| l.match(/rake (\S+)\s+\#\s(.+)/).to_a }.collect { |l| [l[1], l[2]] }).flatten]
41
+
42
+ indent = " "
43
+
44
+ puts "rake #{indent}#Runs the 'default' task"
45
+
46
+ taskHash.each_pair do |key, value|
47
+ if key.nil?
48
+ next
49
+ end
50
+ puts "rake #{key}#{indent.slice(0, indent.length - key.length)}##{value}"
51
+ end
53
52
  end
54
53
 
55
- def regexify(path)
54
+ module RakeDotNet
55
+
56
+
57
+ def RakeDotNet::regexify(path)
56
58
  path.gsub('/', '\/').gsub('.', '\.')
57
59
  end
58
60
 
59
- def find_tools_dir
61
+ def RakeDotNet::find_tools_dir
60
62
  shared = File.join(PRODUCT_ROOT, '..', '3rdparty')
61
63
  owned = File.join(PRODUCT_ROOT, '3rdparty')
62
- if File.exist?(shared)
64
+ if File.exist?(shared)
63
65
  return shared
64
66
  end
65
- if File.exist?(owned)
67
+ if File.exist?(owned)
66
68
  return owned
67
69
  end
68
70
  end
@@ -89,172 +91,380 @@ CLOBBER.include(OUT_DIR)
89
91
  VERBOSE = ENV['VERBOSE'] ? ENV['VERBOSE'] : false
90
92
  verbose(VERBOSE)
91
93
 
94
+ Bin_out = File.join(RakeDotNet::OUT_DIR, 'bin')
92
95
 
93
- module Rake
94
- class AssemblyInfoTask < Rake::TaskLib
95
- attr_accessor :product_name, :configuration, :company_name, :version
96
-
97
- def initialize(params={})
98
- @src_dir = params[:src_dir] || SRC_DIR
99
- yield self if block_given?
100
- define
101
- end
102
-
103
- def define
104
- src_dir_regex = regexify(@src_dir)
105
- rule(/#{src_dir_regex}\/[\w\.\d]+\/Properties\/AssemblyInfo.cs/) do |r|
106
- dir = Pathname.new(r.name).dirname
107
- mkdir_p dir
108
- nextdoor = Pathname.new(r.name + '.template')
109
- common = Pathname.new(File.join(@src_dir, 'AssemblyInfo.cs.template'))
110
- if (nextdoor.exist?)
111
- generate(nextdoor, r.name)
112
- elsif (common.exist?)
113
- generate(common, r.name)
114
- end
115
- end
116
-
117
- rule(/#{src_dir_regex}\/[\w\.\d]+\/My Project\/AssemblyInfo.vb/) do |r|
118
- dir = Pathname.new(r.name).dirname
119
- mkdir_p dir
120
- nextdoor = Pathname.new(r.name + '.template')
121
- common = Pathname.new(File.join(@src_dir, 'AssemblyInfo.vb.template'))
122
- if (nextdoor.exist?)
123
- generate(nextdoor, r.name)
124
- elsif (common.exist?)
125
- generate(common, r.name)
126
- end
127
- end
128
-
129
- desc 'Generate the AssemblyInfo.cs file from the template closest'
130
- task :assembly_info do |t|
131
- Pathname.new(@src_dir).entries.each do |e|
132
- asm_info = asm_info_to_generate(e)
133
- Rake::FileTask[asm_info].invoke unless asm_info.nil?
134
- end
135
- end
136
-
137
- self
138
- end
139
-
140
- def generate(template_file, destination)
141
- content = template_file.read
142
- token_replacements.each do |key, value|
143
- content = content.gsub(/(\$\{#{key}\})/, value.to_s)
144
- end
145
- of = Pathname.new(destination)
146
- of.delete if of.exist?
147
- of.open('w') { |f| f.puts content }
148
- end
149
-
150
- def asm_info_to_generate pn_entry
151
- if (pn_entry == '.' || pn_entry == '..' || pn_entry == '.svn')
152
- return nil
153
- end
154
- if (pn_entry == 'AssemblyInfo.cs.template' || pn_entry == 'AssemblyInfo.vb.template')
155
- return nil
156
- end
157
-
158
- proj = FileList.new("#{@src_dir}/#{pn_entry}/*.*proj").first
159
- return nil if proj.nil?
160
-
161
- proj_ext = Pathname.new(proj).extname
162
- path = case proj_ext
163
- when '.csproj' then File.join(@src_dir, pn_entry, 'Properties', 'AssemblyInfo.cs')
164
- when '.vbproj' then File.join(@src_dir, pn_entry, 'My Project', 'AssemblyInfo.vb')
165
- else nil
166
- end
167
- return path
168
- end
169
-
170
- def token_replacements
171
- r = {}
172
- r[:built_on] = Time.now
173
- r[:product] = product_name
174
- r[:configuration] = configuration
175
- r[:company] = company_name
176
- r[:version] = version
177
- return r
178
- end
179
-
180
- def product_name
181
- @product_name ||= PRODUCT_NAME
182
- end
183
-
184
- def configuration
185
- @configuration ||= CONFIGURATION
186
- end
187
-
188
- def company_name
189
- @company_name ||= COMPANY_NAME
190
- end
191
-
192
- def version
193
- @version ||= Versioner.new.get
194
- end
195
- end
196
- end
197
96
 
97
+ class Cli
98
+ attr_accessor :bin, :search_paths
198
99
 
199
- module Rake
200
- class FxCopTask < TaskLib
201
- attr_accessor :dll_list, :suites_dir
202
-
203
- def initialize(params={})
204
- @product_name = params[:product_name] || PRODUCT_NAME
205
- @report_dir = params[:report_dir] || File.join(OUT_DIR, 'reports')
206
- @name = params[:name] || File.join(@report_dir, @product_name + '.fxcop')
207
- @suites_dir = params[:suites_dir] || File.join(OUT_DIR, "bin-#{CONFIGURATION}-v#{Versioner.new.get}")
208
- @dll_list = FileList.new
209
- @deps = params[:deps] || []
210
- @fxcop_options = params[:fxcop_options] || {}
211
- if @fxcop_options[:apply_out_xsl].nil? || @fxcop_options[:apply_out_xsl] == false
212
- @name += '.xml'
100
+ def initialize(params={})
101
+ @bin = params[:exe] || nil
102
+ @exe_name = params[:exe_name] #required for inferring path
103
+
104
+ # guessable / defaultable
105
+ @search_paths = params[:search_paths] || []
106
+ @search_paths << nil # use the one that will be found in %PATH%
107
+ end
108
+
109
+ def exe
110
+ return @bin unless @bin.nil?
111
+
112
+ @bin = "#{search_for_exe}"
113
+
114
+ return @bin
115
+ end
116
+
117
+ def cmd
118
+ return "\"#{exe}\""
119
+ end
120
+
121
+ def search_for_exe
122
+ @search_paths.each do |sp|
123
+ if sp.nil?
124
+ return @exe_name #because we add bare exe as last element in array
213
125
  else
214
- @name += '.html'
126
+ path = File.join(sp, @exe_name)
127
+ return File.expand_path(path) if File.exist? path
215
128
  end
216
- @fxcop_options[:out_file] = @name if @fxcop_options[:out_file].nil?
217
-
218
- yield self if block_given?
219
- define
220
129
  end
221
-
222
- def define
223
- @deps.each do |d|
224
- task :fxcop => d
130
+ raise(ArgumentError, "No executable found in search-paths or system-PATH", caller)
131
+ end
132
+ end
133
+
134
+
135
+ class BcpCmd < Cli
136
+ attr_accessor :keep_identity_values, :keep_null_values, :wide_character_type, :field_terminator, :native_type
137
+ attr_accessor :direction, :database, :table, :schema, :file
138
+
139
+ def initialize(params={})
140
+ sps = params[:search_paths] || []
141
+ sps << File.join(TOOLS_DIR, 'sql')
142
+ sps << File.join(ENV['PROGRAMFILES'], 'Microsoft SQL Server', '100', 'tools', 'binn')
143
+ sps << File.join(ENV['PROGRAMFILES'], 'Microsoft SQL Server', '90', 'tools', 'binn')
144
+ sps << File.join(ENV['PROGRAMFILES'], 'Microsoft SQL Server', '80', 'tools', 'binn')
145
+ super(params.merge({:exe_name=>'bcp.exe', :search_paths=>sps}))
146
+
147
+ unless params[:trusted].nil?
148
+ @trusted = params[:trusted]
149
+ else
150
+ @trusted = true
151
+ end
152
+ unless @trusted
153
+ @user = params[:user] || DB_USER
154
+ @password = params[:password] || DB_PASSWORD
155
+ end
156
+
157
+ @server = params[:server] || DB_SERVER
158
+
159
+ @database = params[:database] unless params[:database].nil?
160
+ @schema = params[:schema] || 'dbo'
161
+ @table = params[:table] unless params[:table].nil?
162
+ @direction = params[:direction] unless params[:direction].nil?
163
+ @file = params[:file] unless params[:file].nil?
164
+ end
165
+
166
+ def credentials
167
+ if @trusted
168
+ return '-T'
169
+ else
170
+ return "-U \"#{@user}\" -P \"#{@password}\""
171
+ end
172
+ end
173
+
174
+ def server
175
+ return "-S \"#{@server}\""
176
+ end
177
+
178
+ def direction
179
+ return @direction.to_s
180
+ end
181
+
182
+ def db_object
183
+ return "[#{@database}].[#{@schema}].[#{@table}]"
184
+ end
185
+
186
+ def path
187
+ return '"' + File.expand_path(@file).gsub('/', '\\') + '"'
188
+ end
189
+
190
+ def keep_identity_values
191
+ return '-E' unless @keep_identity_values.nil?
192
+ end
193
+
194
+ def keep_null_values
195
+ return '-k' unless @keep_null_values.nil?
196
+ end
197
+
198
+ def wide_character_type
199
+ return '-w' unless @wide_character_type.nil?
200
+ end
201
+
202
+ def field_terminator
203
+ return "-t '#{@field_terminator}'" unless @field_terminator.nil?
204
+ end
205
+
206
+ def native_type
207
+ return '-n' unless @native_type.nil?
208
+ end
209
+
210
+ def cmd
211
+ return "#{exe} #{db_object} #{direction} #{path} #{server} #{credentials} #{keep_identity_values} #{keep_null_values} #{wide_character_type} #{field_terminator} #{native_type}"
212
+ end
213
+
214
+ def revert_optionals
215
+ @keep_identity_values = nil
216
+ @keep_null_values = nil
217
+ @wide_character_type = nil
218
+ @field_terminator = nil
219
+ @native_type = nil
220
+ @direction = nil
221
+ end
222
+
223
+ def run
224
+ puts cmd if VERBOSE == true
225
+ sh cmd
226
+ revert_optionals
227
+ end
228
+ end
229
+
230
+
231
+ class SqlCmd < Cli
232
+ attr_accessor :input_file, :query, :database
233
+
234
+ def initialize(params={})
235
+ sps = params[:search_paths] || []
236
+ sps << File.join(TOOLS_DIR, 'sql')
237
+ sps << File.join(ENV['PROGRAMFILES'], 'Microsoft SQL Server', '100', 'tools', 'binn')
238
+ sps << File.join(ENV['PROGRAMFILES'], 'Microsoft SQL Server', '90', 'tools', 'binn')
239
+ sps << File.join(ENV['PROGRAMFILES'], 'Microsoft SQL Server', '80', 'tools', 'binn')
240
+ super(params.merge({:exe_name=>'sqlcmd.exe', :search_paths=>sps}))
241
+
242
+ unless params[:trusted].nil?
243
+ @trusted = params[:trusted]
244
+ else
245
+ @trusted = true
246
+ end
247
+ unless @trusted
248
+ @user = params[:user] || DB_USER
249
+ @password = params[:password] || DB_PASSWORD
250
+ end
251
+ @server = params[:server] || DB_SERVER
252
+
253
+ #optionals and runtime settable
254
+ @input_file = params[:input_file]
255
+ @query = params[:query]
256
+ end
257
+
258
+ def credentials
259
+ if @trusted
260
+ return '-E'
261
+ else
262
+ return "-U \"#{@user}\" -P \"#{@password}\""
263
+ end
264
+ end
265
+
266
+ def server
267
+ return "-S \"#{@server}\""
268
+ end
269
+
270
+ def database
271
+ return "-d \"#{@database}\"" unless @database.nil?
272
+ end
273
+
274
+ def input_file
275
+ unless @input_file.nil?
276
+ path = File.expand_path(@input_file).gsub('/', "\\")
277
+ return "-i \"#{path}\""
278
+ end
279
+ return ''
280
+ end
281
+
282
+ def query
283
+ return "-Q \"#{@query}\"" unless @query.nil?
284
+ end
285
+
286
+ def cmd
287
+ return "#{exe} #{server} #{credentials} #{database} #{input_file} #{query}"
288
+ end
289
+
290
+ def run
291
+ puts cmd if VERBOSE == true
292
+ sh cmd
293
+ revert_optionals
294
+ end
295
+
296
+ def revert_optionals
297
+ @query = nil
298
+ @input_file = nil
299
+ end
300
+ end
301
+
302
+
303
+ class AssemblyInfoTask < Rake::TaskLib
304
+ attr_accessor :product_name, :configuration, :company_name, :version
305
+
306
+ def initialize(params={})
307
+ @src_dir = params[:src_dir] || SRC_DIR
308
+ yield self if block_given?
309
+ define
310
+ end
311
+
312
+ def define
313
+ src_dir_regex = RakeDotNet::regexify(@src_dir)
314
+ rule(/#{src_dir_regex}\/[\w\.\d]+\/Properties\/AssemblyInfo.cs/) do |r|
315
+ dir = Pathname.new(r.name).dirname
316
+ mkdir_p dir
317
+ nextdoor = Pathname.new(r.name + '.template')
318
+ common = Pathname.new(File.join(@src_dir, 'AssemblyInfo.cs.template'))
319
+ if (nextdoor.exist?)
320
+ generate(nextdoor, r.name)
321
+ elsif (common.exist?)
322
+ generate(common, r.name)
225
323
  end
226
-
227
- directory @report_dir
324
+ end
228
325
 
229
- file @name => [@report_dir] do |f|
230
- runner = FxCop.new(@dll_list, @fxcop_options)
231
- runner.run
326
+ rule(/#{src_dir_regex}\/[\w\.\d]+\/My Project\/AssemblyInfo.vb/) do |r|
327
+ dir = Pathname.new(r.name).dirname
328
+ mkdir_p dir
329
+ nextdoor = Pathname.new(r.name + '.template')
330
+ common = Pathname.new(File.join(@src_dir, 'AssemblyInfo.vb.template'))
331
+ if (nextdoor.exist?)
332
+ generate(nextdoor, r.name)
333
+ elsif (common.exist?)
334
+ generate(common, r.name)
232
335
  end
233
-
234
- task :fxcop,[:include_globs, :exclude_globs] do |t, args|
235
- args.with_defaults(:include_globs => ["#{@suites_dir}/**/*#{@product_name}*.dll", "#{@suites_dir}/**/*#{@product_name}*.exe"])
236
- args.include_globs.each do |g|
237
- @dll_list.include g
238
- end
239
- args.with_defaults(:exclude_globs => ["#{@suites_dir}/*Tests*.dll", "#{@suites_dir}/*.vshost.exe"])
240
- args.exclude_globs.each do |g|
241
- @dll_list.exclude g
336
+ end
337
+
338
+ desc 'Generate the AssemblyInfo.cs file from the template closest'
339
+ task :assembly_info do |t|
340
+ Pathname.new(@src_dir).entries.each do |e|
341
+ asm_info = asm_info_to_generate(e)
342
+ Rake::FileTask[asm_info].invoke unless asm_info.nil?
343
+ end
344
+ end
345
+
346
+ self
347
+ end
348
+
349
+ def generate(template_file, destination)
350
+ content = template_file.read
351
+ token_replacements.each do |key, value|
352
+ content = content.gsub(/(\$\{#{key}\})/, value.to_s)
353
+ end
354
+ of = Pathname.new(destination)
355
+ of.delete if of.exist?
356
+ of.open('w') { |f| f.puts content }
357
+ end
358
+
359
+ def asm_info_to_generate pn_entry
360
+ if (pn_entry == '.' || pn_entry == '..' || pn_entry == '.svn')
361
+ return nil
362
+ end
363
+ if (pn_entry == 'AssemblyInfo.cs.template' || pn_entry == 'AssemblyInfo.vb.template')
364
+ return nil
365
+ end
366
+
367
+ proj = FileList.new("#{@src_dir}/#{pn_entry}/*.*proj").first
368
+ return nil if proj.nil?
369
+
370
+ proj_ext = Pathname.new(proj).extname
371
+ path =
372
+ case proj_ext
373
+ when '.csproj' then
374
+ File.join(@src_dir, pn_entry, 'Properties', 'AssemblyInfo.cs')
375
+ when '.vbproj' then
376
+ File.join(@src_dir, pn_entry, 'My Project', 'AssemblyInfo.vb')
377
+ else
378
+ nil
242
379
  end
243
- Rake::FileTask[@name].invoke
380
+ return path
381
+ end
382
+
383
+ def token_replacements
384
+ r = {}
385
+ r[:built_on] = Time.now
386
+ r[:product] = product_name
387
+ r[:configuration] = configuration
388
+ r[:company] = company_name
389
+ r[:version] = version
390
+ return r
391
+ end
392
+
393
+ def product_name
394
+ @product_name ||= PRODUCT_NAME
395
+ end
396
+
397
+ def configuration
398
+ @configuration ||= CONFIGURATION
399
+ end
400
+
401
+ def company_name
402
+ @company_name ||= COMPANY_NAME
403
+ end
404
+
405
+ def version
406
+ @version ||= Versioner.new.get
407
+ end
408
+ end
409
+
410
+
411
+ class FxCopTask < Rake::TaskLib
412
+ attr_accessor :dll_list, :suites_dir
413
+
414
+ def initialize(params={})
415
+ @product_name = params[:product_name] || PRODUCT_NAME
416
+ @report_dir = params[:report_dir] || File.join(OUT_DIR, 'reports')
417
+ @name = params[:name] || File.join(@report_dir, @product_name + '.fxcop')
418
+ @suites_dir = params[:suites_dir] || File.join(OUT_DIR, 'bin')
419
+ @dll_list = FileList.new
420
+ @deps = params[:deps] || []
421
+ @fxcop_options = params[:fxcop_options] || {}
422
+ if @fxcop_options[:apply_out_xsl].nil? || @fxcop_options[:apply_out_xsl] == false
423
+ @name += '.xml'
424
+ else
425
+ @name += '.html'
426
+ end
427
+ @fxcop_options[:out_file] = @name if @fxcop_options[:out_file].nil?
428
+
429
+ yield self if block_given?
430
+ define
431
+ end
432
+
433
+ def define
434
+ @deps.each do |d|
435
+ task :fxcop => d
436
+ end
437
+
438
+ directory @report_dir
439
+
440
+ file @name => [@report_dir] do |f|
441
+ runner = FxCop.new(@dll_list, @fxcop_options)
442
+ runner.run
443
+ end
444
+
445
+ task :fxcop, [:include_globs, :exclude_globs] do |t, args|
446
+ args.with_defaults(:include_globs => ["#{@suites_dir}/**/*#{@product_name}*.dll", "#{@suites_dir}/**/*#{@product_name}*.exe"])
447
+ args.include_globs.each do |g|
448
+ @dll_list.include g
244
449
  end
245
-
246
- task :clobber_fxcop,[:globs] do |t, args|
247
- rm_rf @report_dir
450
+ args.with_defaults(:exclude_globs => ["#{@suites_dir}/*Tests*.dll", "#{@suites_dir}/*.vshost.exe"])
451
+ args.exclude_globs.each do |g|
452
+ @dll_list.exclude g
248
453
  end
249
-
250
- self
454
+ Rake::FileTask[@name].invoke
251
455
  end
252
-
456
+
457
+ task :clobber_fxcop, [:globs] do |t, args|
458
+ rm_rf @report_dir
459
+ end
460
+
253
461
  self
254
462
  end
463
+
464
+ self
255
465
  end
256
466
 
257
- class FxCop
467
+ class FxCopCmd
258
468
  attr_accessor :dlls, :out_file, :out_xsl, :apply_out_xsl, :dependencies_path, :summary, :verbose, :echo_to_console, :xsl_echo_to_console, :ignore_autogen, :culture
259
469
 
260
470
  def initialize(dlls, params={})
@@ -273,10 +483,10 @@ class FxCop
273
483
  @summary = params[:summary]
274
484
  @verbose = params[:verbose]
275
485
  @xsl_echo_to_console = params[:xsl_echo_to_console]
276
-
486
+
277
487
  yield self if block_given?
278
488
  end
279
-
489
+
280
490
  def console
281
491
  '/console' if @echo_to_console || @out_file.nil?
282
492
  end
@@ -300,7 +510,7 @@ class FxCop
300
510
  def apply_out_xsl
301
511
  "/applyoutxsl" if @apply_out_xsl
302
512
  end
303
-
513
+
304
514
  def cmd
305
515
  "\"#{@exe}\" #{files_to_analyse} #{console} #{out_file} #{out_xsl} #{apply_out_xsl}"
306
516
  end
@@ -313,122 +523,116 @@ class FxCop
313
523
  end
314
524
 
315
525
 
316
- module Rake
317
- class HarvestOutputTask < TaskLib
318
- def initialize(params={})
319
- @src_path = params[:src_path] || File.join(PRODUCT_ROOT, 'src')
320
- @deps = params[:deps] || []
321
- @configuration = params[:configuration] || CONFIGURATION
322
- @version = params[:version] || Versioner.new.get
323
- @target_path = params[:target_path] || File.join(OUT_DIR, "bin-#{@configuration}-v#{@version}")
324
- @glob = params[:glob] || "#{@src_path}/*"
325
-
326
- yield self if block_given?
327
- define
328
- end
329
-
330
- def define
331
- directory @target_path
332
-
333
- desc "Harvest specified libraries (or all matching #{@glob}) to #{@target_path}"
334
- task :harvest_output,[:to_harvest_list] => @target_path do |t, args|
335
- list = FileList.new
336
- @glob.each do |g|
337
- list.include(g)
338
- end
339
- args.with_defaults(:to_harvest_list => list)
340
- args.to_harvest_list.each do |entry|
341
- pn = Pathname.new(entry)
342
- if pn.directory?
343
- output = FileList.new
344
- #TODO: distinguish between web and class and console output
345
- output.include("#{entry}/bin/#{@configuration}/*")
346
- output.include("#{entry}/bin/*")
347
- output.each do |o|
348
- o_pn = Pathname.new(o)
349
- to_pn = Pathname.new("#{@target_path}")
350
- if (o_pn.directory?)
351
- cp_r(o, to_pn) unless o_pn.to_s.match(/#{@configuration}$/)
352
- else
353
- cp(o, to_pn)
354
- end
526
+ class HarvestOutputTask < Rake::TaskLib
527
+ def initialize(params={})
528
+ @src_path = params[:src_path] || File.join(PRODUCT_ROOT, 'src')
529
+ @target_path = params[:target_path] || Bin_out
530
+ @deps = params[:deps] || []
531
+ @configuration = params[:configuration] || CONFIGURATION
532
+ @glob = params[:glob] || "#{@src_path}/*"
533
+
534
+ yield self if block_given?
535
+ define
536
+ end
537
+
538
+ def define
539
+ directory @target_path
540
+
541
+ desc "Harvest specified libraries (or all matching #{@glob}) to #{@target_path}"
542
+ task :harvest_output, [:to_harvest_list] => @target_path do |t, args|
543
+ list = FileList.new
544
+ @glob.each do |g|
545
+ list.include(g)
546
+ end
547
+ args.with_defaults(:to_harvest_list => list)
548
+ args.to_harvest_list.each do |entry|
549
+ pn = Pathname.new(entry)
550
+ if pn.directory?
551
+ output = FileList.new
552
+ #TODO: distinguish between web and class and console output
553
+ output.include("#{entry}/bin/#{@configuration}/*")
554
+ output.include("#{entry}/bin/*")
555
+ output.each do |o|
556
+ o_pn = Pathname.new(o)
557
+ to_pn = Pathname.new("#{@target_path}")
558
+ if (o_pn.directory?)
559
+ cp_r(o, to_pn) unless o_pn.to_s.match(/#{@configuration}$/)
560
+ else
561
+ cp(o, to_pn)
355
562
  end
356
563
  end
357
564
  end
358
565
  end
359
-
360
- @deps.each do |d|
361
- task :harvest => d
362
- end
363
-
364
- self
365
566
  end
567
+
568
+ @deps.each do |d|
569
+ task :harvest => d
570
+ end
571
+
572
+ self
573
+ end
574
+ end
575
+
576
+ class HarvestWebApplicationTask < Rake::TaskLib
577
+ def initialize(params={})
578
+ @src_path = params[:src_path] || File.join(PRODUCT_ROOT, 'src')
579
+ @target_path = params[:target_path] || OUT_DIR
580
+ @deps = params[:deps] || []
581
+ @glob = params[:glob] || "**/*.Site"
582
+
583
+ yield self if block_given?
584
+ define
366
585
  end
367
586
 
368
- class HarvestWebApplicationTask < TaskLib
369
- def initialize(params={})
370
- @src_path = params[:src_path] || File.join(PRODUCT_ROOT, 'src')
371
- @target_path = params[:target_path] || OUT_DIR
372
- @deps = params[:deps] || []
373
- @configuration = params[:configuration] || CONFIGURATION
374
- @version = params[:version] || Versioner.new.get
375
- @glob = params[:glob] || "**/*.Site"
376
-
377
- yield self if block_given?
378
- define
587
+ def define
588
+ out_dir_regex = RakeDotNet::regexify(@target_path)
589
+
590
+ odr = /#{out_dir_regex}\/([\w\.-_ ]*Site)\//
591
+ rule(odr) do |r|
592
+ harvest(r.name, odr)
379
593
  end
380
594
 
381
- def define
382
- out_dir_regex = regexify(@target_path)
383
-
384
- # config/version included
385
- versioned_regex = /#{out_dir_regex}\/([\w\.-_ ]*Site)-\w+-v\d+\.\d+\.\d+\.\d+\//
386
- rule(versioned_regex) do |r|
387
- harvest(r.name, versioned_regex)
388
- end
389
-
390
- desc "Harvest specified web-applications (or all matching #{@src_path}/#{@glob}) to #{@target_path}"
391
- task :harvest_webapps,[:web_app_list] => @target_path do |t, args|
392
- list = FileList.new("#{@src_path}/#{@glob}")
393
- args.with_defaults(:web_app_list => list)
394
- args.web_app_list.each do |w|
395
- pn = Pathname.new(w)
396
- out = File.join(@target_path, "#{pn.basename}-#{@configuration}-v#{@version}") + '/'
397
- Rake::FileTask[out].invoke
398
- end
399
- end
400
-
401
- @deps.each do |d|
402
- task :harvest_webapps => d
595
+ desc "Harvest specified web-applications (or all matching #{@src_path}/#{@glob}) to #{@target_path}"
596
+ task :harvest_webapps, [:web_app_list] => @target_path do |t, args|
597
+ list = FileList.new("#{@src_path}/#{@glob}")
598
+ args.with_defaults(:web_app_list => list)
599
+ args.web_app_list.each do |w|
600
+ pn = Pathname.new(w)
601
+ out = File.join(@target_path, pn.basename) + '/'
602
+ Rake::FileTask[out].invoke
403
603
  end
404
-
405
- self
406
604
  end
407
-
408
- def harvest(path, regex)
409
- web_app_name = path.match(regex)[1]
410
- src = File.join(@src_path, web_app_name)
411
- if (File.exist?("#{src}/.svn"))
412
- svn = SvnExport.new(src, path)
413
- svn.export
414
- cp_r(File.join(src, 'bin'), path)
415
- else
416
- cp_r src, path
417
- end
418
- FileList.new("#{path}**/obj").each do |e|
419
- rm_rf e if File.exist? e
420
- end
605
+
606
+ @deps.each do |d|
607
+ task :harvest_webapps => d
608
+ end
609
+
610
+ self
611
+ end
612
+
613
+ def harvest(path, regex)
614
+ web_app_name = path.match(regex)[1]
615
+ src = File.join(@src_path, web_app_name)
616
+ if (File.exist?("#{src}/.svn"))
617
+ svn = SvnExport.new({:src=>src, :dest=>path})
618
+ svn.run
619
+ cp_r(File.join(src, 'bin'), path)
620
+ else
621
+ cp_r src, path
622
+ end
623
+ FileList.new("#{path}**/obj").each do |e|
624
+ rm_rf e if File.exist? e
421
625
  end
422
626
  end
423
627
  end
424
628
 
425
629
  class Harvester
426
630
  attr_accessor :files, :target
427
-
631
+
428
632
  def initialize
429
633
  @files = Hash.new
430
634
  end
431
-
635
+
432
636
  def add(glob)
433
637
  toAdd = Dir.glob(glob)
434
638
  toAdd.each do |a|
@@ -436,91 +640,89 @@ class Harvester
436
640
  @files[pn.basename.to_s] = pn
437
641
  end
438
642
  end
439
-
643
+
440
644
  def harvest(target)
441
645
  mkdir_p(target) unless File.exist?(target)
442
646
  @files.sort.each do |k, v|
443
647
  cp(v, target)
444
648
  end
445
649
  end
446
-
650
+
447
651
  def list
448
- @files.sort.each do |k, v|
652
+ @files.sort.each do |k, v|
449
653
  puts k + ' -> ' + v
450
654
  end
451
655
  end
452
656
  end
453
657
 
454
658
 
455
- module Rake
456
- class MsBuildTask < TaskLib
457
- attr_accessor :src_dir, :verbosity, :working_dir
458
-
459
- def initialize(params={})
460
- #TODO: Support for arbitrary properties, not just configuration. For example, TreatWarningsAsErrors, WarningLevel.
461
- @configuration = params[:configuration] || CONFIGURATION
462
- @src_dir = params[:src_dir] || SRC_DIR
463
- @verbosity = params[:verbosity] || MSBUILD_VERBOSITY || 'm'
464
- @working_dir = params[:working_dir] || '.'
465
- @deps = params[:deps] || []
466
- @buildable_projects = ['.csproj','.vbproj','.wixproj']
467
- @properties = {:Configuration => @configuration, :TreatWarningsAsErrors => true, :WarningLevel => 4, :BuildInParallel => true}.merge(params[:properties] || {})
468
-
469
- yield self if block_given?
470
- define
659
+ class MsBuildTask < Rake::TaskLib
660
+ attr_accessor :src_dir, :verbosity, :working_dir
661
+
662
+ def initialize(params={})
663
+ #TODO: Support for arbitrary properties, not just configuration. For example, TreatWarningsAsErrors, WarningLevel.
664
+ @configuration = params[:configuration] || CONFIGURATION
665
+ @src_dir = params[:src_dir] || SRC_DIR
666
+ @verbosity = params[:verbosity] || MSBUILD_VERBOSITY || 'm'
667
+ @working_dir = params[:working_dir] || '.'
668
+ @deps = params[:deps] || [Bin_out]
669
+ @buildable_projects = ['.csproj', '.vbproj', '.wixproj']
670
+ @properties = {:Configuration => @configuration, :TreatWarningsAsErrors => true, :WarningLevel => 4, :BuildInParallel => true}.merge(params[:properties] || {})
671
+
672
+ yield self if block_given?
673
+ define
674
+ end
675
+
676
+ def define
677
+ # most project types put output into bin/{configuration}
678
+ rule(/#{src_dir_regex}\/[\w\.]+\/bin\/#{@configuration}\/[\w\.]+\.(?:dll|exe)/) do |r|
679
+ pn = Pathname.new(r.name)
680
+ name = pn.basename.to_s.sub('.dll', '')
681
+ project = FileList.new("#{@src_dir}/#{name}/#{name}.*proj").first
682
+ mb = MsBuildCmd.new(project, @properties, ['Build'], verbosity, @working_dir)
683
+ mb.run
471
684
  end
472
-
473
- def define
474
- # most project types put output into bin/{configuration}
475
- rule(/#{src_dir_regex}\/[\w\.]+\/bin\/#{@configuration}\/[\w\.]+\.(?:dll|exe)/) do |r|
476
- pn = Pathname.new(r.name)
477
- name = pn.basename.to_s.sub('.dll', '')
478
- project = FileList.new("#{@src_dir}/#{name}/#{name}.*proj").first
479
- mb = MsBuild.new(project, @properties, ['Build'], verbosity, @working_dir)
480
- mb.run
481
- end
482
-
483
- # web application projects put output into /bin
484
- rule(/#{src_dir_regex}\/[\w\.]+\/bin\/[\w\.]+\.dll/) do |r|
485
- pn = Pathname.new(r.name)
486
- name = pn.basename.to_s.sub('.dll', '')
487
- project = FileList.new("#{@src_dir}/#{name}/#{name}.*proj").first
488
- mb = MsBuild.new(project, @properties, ['Build'], verbosity, @working_dir)
489
- mb.run
490
- end
491
685
 
492
- desc "Compile the specified projects (give relative paths) (otherwise, all matching src/**/*.*proj)"
493
- task :compile,[:projects] do |t, args|
494
- project_list = FileList.new("#{src_dir}/**/*.*proj")
495
- args.with_defaults(:projects => project_list)
496
- args.projects.each do |p|
497
- pn = Pathname.new(p)
498
- # TODO: Figure out which type of project we are so we can invoke the correct rule, with the correct output extension
499
- dll = File.join(pn.dirname, 'bin', @configuration, pn.basename.sub(pn.extname, '.dll'))
500
- Rake::FileTask[dll].invoke if @buildable_projects.include?(pn.extname)
501
- end
502
- end
686
+ # web application projects put output into /bin
687
+ rule(/#{src_dir_regex}\/[\w\.]+\/bin\/[\w\.]+\.dll/) do |r|
688
+ pn = Pathname.new(r.name)
689
+ name = pn.basename.to_s.sub('.dll', '')
690
+ project = FileList.new("#{@src_dir}/#{name}/#{name}.*proj").first
691
+ mb = MsBuildCmd.new(project, @properties, ['Build'], verbosity, @working_dir)
692
+ mb.run
693
+ end
503
694
 
504
- @deps.each do |d|
505
- task :compile => d
695
+ desc "Compile the specified projects (give relative paths) (otherwise, all matching src/**/*.*proj)"
696
+ task :compile, [:projects] do |t, args|
697
+ project_list = FileList.new("#{src_dir}/**/*.*proj")
698
+ args.with_defaults(:projects => project_list)
699
+ args.projects.each do |p|
700
+ pn = Pathname.new(p)
701
+ # TODO: Figure out which type of project we are so we can invoke the correct rule, with the correct output extension
702
+ dll = File.join(pn.dirname, 'bin', @configuration, pn.basename.sub(pn.extname, '.dll'))
703
+ Rake::FileTask[dll].invoke if @buildable_projects.include?(pn.extname)
506
704
  end
507
-
508
- self
509
- end
510
-
511
- def src_dir_regex
512
- regexify(@src_dir)
513
705
  end
514
-
515
- def figure_out_project_type(project_pathname)
516
- # TODO.
706
+
707
+ @deps.each do |d|
708
+ task :compile => d
517
709
  end
710
+
711
+ self
712
+ end
713
+
714
+ def src_dir_regex
715
+ RakeDotNet::regexify(@src_dir)
716
+ end
717
+
718
+ def figure_out_project_type(project_pathname)
719
+ # TODO.
518
720
  end
519
721
  end
520
722
 
521
- class MsBuild
723
+ class MsBuildCmd
522
724
  attr_accessor :project, :properties, :targets, :verbosity
523
-
725
+
524
726
  def initialize(project='default.proj', properties={}, targets=[], verbosity='n', working_dir=nil)
525
727
  @project = project
526
728
  @properties = properties
@@ -529,11 +731,11 @@ class MsBuild
529
731
  @working_dir = working_dir
530
732
  @exe = '"' + File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', 'v3.5', 'msbuild.exe') + '"'
531
733
  end
532
-
734
+
533
735
  def cmd
534
736
  "#{@exe} #{project} /maxcpucount /v:#{@verbosity} /p:#{properties} /t:#{targets}"
535
737
  end
536
-
738
+
537
739
  def run
538
740
  if @working_dir
539
741
  chdir(@working_dir) do
@@ -542,15 +744,15 @@ class MsBuild
542
744
  end
543
745
  end
544
746
  end
545
-
747
+
546
748
  def project
547
749
  "\"#{@project}\""
548
750
  end
549
-
751
+
550
752
  def targets
551
753
  @targets.join(';')
552
754
  end
553
-
755
+
554
756
  def properties
555
757
  p = []
556
758
  @properties.each {|key, value| p.push("#{key}=#{value}") }
@@ -559,70 +761,69 @@ class MsBuild
559
761
  end
560
762
 
561
763
 
562
- module Rake
563
- class NCoverTask < TaskLib
564
- attr_accessor :profile_options, :reporting_options
565
- def initialize(params={})
566
- @product_name = params[:product_name] || PRODUCT_NAME
567
- @bin_dir = params[:bin_dir] || File.join(OUT_DIR, "bin-#{CONFIGURATION}-v#{Versioner.new.get}")
568
- @report_dir = params[:report_dir] || File.join(OUT_DIR, 'reports', 'ncover')
569
- @deps = params[:deps] || []
570
- tool_defaults = {:arch => ENV['PROCESSOR_ARCHITECTURE']}
571
- @profile_options = tool_defaults.merge(params[:profile_options] || {})
572
- @reporting_options = tool_defaults.merge(params[:reporting_options] || {})
573
-
574
- yield self if block_given?
575
- define
764
+ class NCoverTask < Rake::TaskLib
765
+ attr_accessor :profile_options, :reporting_options
766
+
767
+ def initialize(params={})
768
+ @product_name = params[:product_name] || PRODUCT_NAME
769
+ @bin_dir = params[:bin_dir] || File.join(OUT_DIR, 'bin')
770
+ @report_dir = params[:report_dir] || File.join(OUT_DIR, 'reports', 'ncover')
771
+ @deps = params[:deps] || []
772
+ tool_defaults = {:arch => ENV['PROCESSOR_ARCHITECTURE']}
773
+ @profile_options = tool_defaults.merge(params[:profile_options] || {})
774
+ @reporting_options = tool_defaults.merge(params[:reporting_options] || {})
775
+
776
+ yield self if block_given?
777
+ define
778
+ end
779
+
780
+ def define
781
+ @deps.each do |d|
782
+ task :ncover_profile => d
783
+ end
784
+
785
+ directory @report_dir
786
+
787
+ reports_dir_regex = RakeDotNet::regexify(@report_dir)
788
+ rule(/#{reports_dir_regex}\/.*\.coverage\.xml/) do |r|
789
+ dll_to_execute = r.name.sub(/#{@report_dir}\/(.*)\.coverage\.xml/, "#{@bin_dir}/\\1.dll")
790
+ nc = NCoverConsoleCmd.new(@report_dir, dll_to_execute, @profile_options)
791
+ nc.run
576
792
  end
577
-
578
- def define
579
- @deps.each do |d|
580
- task :ncover_profile => d
581
- end
582
-
583
- directory @report_dir
584
-
585
- reports_dir_regex = regexify(@report_dir)
586
- rule(/#{reports_dir_regex}\/.*\.coverage\.xml/) do |r|
587
- dll_to_execute = r.name.sub(/#{@report_dir}\/(.*)\.coverage\.xml/, "#{@bin_dir}/\\1.dll")
588
- nc = NCover.new(@report_dir, dll_to_execute, @profile_options)
589
- nc.run
590
- end
591
-
592
- desc "Generate ncover coverage XML, one file per test-suite that exercises your product"
593
- task :ncover_profile,[:dlls_to_run] => [@report_dir] do |t, args|
594
- dlls_to_run_list = FileList.new
595
- dlls_to_run_list.include("#{@bin_dir}/**/*#{@product_name}*Tests*.dll")
596
- dlls_to_run_list.include("#{@bin_dir}/**/*#{@product_name}*Tests*.exe")
597
- args.with_defaults(:dlls_to_run => dlls_to_run_list)
598
- args.dlls_to_run.each do |d|
599
- dll_to_run = Pathname.new(d)
600
- cf_name = dll_to_run.basename.sub(dll_to_run.extname, '.coverage.xml')
601
- coverage_file = File.join(@report_dir, cf_name)
602
- Rake::FileTask[coverage_file].invoke
603
- end
604
-
605
- end
606
-
607
- desc "Generate ncover coverage report(s), on all coverage files, merged together"
608
- task :ncover_reports => [:ncover_profile] do
609
- # ncover lets us use *.coverage.xml to merge together files
610
- include = [File.join(@report_dir, '*.coverage.xml')]
611
- @reporting_options[:name] = 'merged'
612
- ncr = NCoverReporting.new(@report_dir, include, @reporting_options)
613
- ncr.run
614
- end
615
-
616
- task :clobber_ncover do
617
- rm_rf @report_dir
793
+
794
+ desc "Generate ncover coverage XML, one file per test-suite that exercises your product"
795
+ task :ncover_profile, [:dlls_to_run] => [@report_dir] do |t, args|
796
+ dlls_to_run_list = FileList.new
797
+ dlls_to_run_list.include("#{@bin_dir}/**/*#{@product_name}*Tests*.dll")
798
+ dlls_to_run_list.include("#{@bin_dir}/**/*#{@product_name}*Tests*.exe")
799
+ args.with_defaults(:dlls_to_run => dlls_to_run_list)
800
+ args.dlls_to_run.each do |d|
801
+ dll_to_run = Pathname.new(d)
802
+ cf_name = dll_to_run.basename.sub(dll_to_run.extname, '.coverage.xml')
803
+ coverage_file = File.join(@report_dir, cf_name)
804
+ Rake::FileTask[coverage_file].invoke
618
805
  end
619
-
620
- self
806
+
807
+ end
808
+
809
+ desc "Generate ncover coverage report(s), on all coverage files, merged together"
810
+ task :ncover_reports => [:ncover_profile] do
811
+ # ncover lets us use *.coverage.xml to merge together files
812
+ include = [File.join(@report_dir, '*.coverage.xml')]
813
+ @reporting_options[:name] = 'merged'
814
+ ncr = NCoverReportingCmd.new(@report_dir, include, @reporting_options)
815
+ ncr.run
816
+ end
817
+
818
+ task :clobber_ncover do
819
+ rm_rf @report_dir
621
820
  end
821
+
822
+ self
622
823
  end
623
824
  end
624
825
 
625
- class NCover
826
+ class NCoverConsoleCmd
626
827
  def initialize(report_dir, dll_to_execute, params)
627
828
  params ||= {}
628
829
  arch = params[:arch] || ENV['PROCESSOR_ARCHITECTURE']
@@ -632,23 +833,22 @@ class NCover
632
833
  @output_file = File.join(report_dir, ofname)
633
834
  @exclude_assemblies_regex = params[:exclude_assemblies_regex] || ['.*Tests.*']
634
835
  @exclude_assemblies_regex.push('ISymWrapper')
635
- @build_id = params[:build_id] || Versioner.new.get
636
836
  @working_dir = params[:working_dir] || Pathname.new(@dll_to_execute).dirname
637
837
  end
638
-
838
+
639
839
  def cmdToRun
640
- x = XUnit.new(@dll_to_execute, '', nil, {})
840
+ x = XUnitConsoleCmd.new(@dll_to_execute, '', nil, {})
641
841
  x.cmd
642
842
  end
643
-
843
+
644
844
  def bi
645
- "//bi #{@build_id.to_s}"
845
+ "//bi #{Versioner.new.get.to_s}"
646
846
  end
647
-
847
+
648
848
  def working_dir
649
849
  "//w #{@working_dir}"
650
850
  end
651
-
851
+
652
852
  def exclude_assemblies
653
853
  if @exclude_assemblies_regex.instance_of?(Array)
654
854
  return '//eas ' + @exclude_assemblies_regex.join(';')
@@ -659,14 +859,14 @@ class NCover
659
859
  def cmd
660
860
  "\"#{@exe}\" #{cmdToRun} //x #{@output_file} #{exclude_assemblies} #{bi} #{working_dir}"
661
861
  end
662
-
862
+
663
863
  def run
664
864
  puts cmd if VERBOSE
665
865
  sh cmd
666
866
  end
667
867
  end
668
868
 
669
- class NCoverReporting
869
+ class NCoverReportingCmd
670
870
  def initialize(report_dir, coverage_files, params)
671
871
  @report_dir = report_dir
672
872
  @coverage_files = coverage_files || []
@@ -678,13 +878,12 @@ class NCoverReporting
678
878
  # required
679
879
  @reports = params[:reports] || ['Summary', 'UncoveredCodeSections', 'FullCoverageReport']
680
880
  @output_path = File.join(@report_dir)
681
-
881
+
682
882
  # optional
683
- @build_id = params[:build_id] || Versioner.new.get
684
883
  @sort_order = params[:sort] || 'CoveragePercentageAscending'
685
884
  @project_name = params[:project_name] || PRODUCT_NAME
686
885
  end
687
-
886
+
688
887
  def coverage_files
689
888
  list = ''
690
889
  @coverage_files.each do |cf|
@@ -692,11 +891,11 @@ class NCoverReporting
692
891
  end
693
892
  list
694
893
  end
695
-
894
+
696
895
  def build_id
697
- "//bi #{@build_id.to_s}"
896
+ "//bi #{Versioner.new.get.to_s}"
698
897
  end
699
-
898
+
700
899
  def output_reports
701
900
  cmd = ''
702
901
  @reports.each do |r|
@@ -704,143 +903,150 @@ class NCoverReporting
704
903
  end
705
904
  return cmd
706
905
  end
707
-
906
+
708
907
  def output_path
709
908
  "//op \"#{@output_path}\""
710
909
  end
711
-
910
+
712
911
  def sort_order
713
912
  "//so #{@sort_order}"
714
913
  end
715
-
914
+
716
915
  def project_name
717
916
  "//p #{@project_name}" unless @project_name.nil?
718
917
  end
719
-
918
+
720
919
  def cmd
721
920
  "\"#{@exe}\" #{coverage_files} #{build_id} #{output_reports} #{output_path} #{sort_order} #{project_name}"
722
921
  end
723
-
922
+
724
923
  def run
725
924
  sh cmd
726
925
  end
727
926
  end
728
927
 
729
928
 
730
- module Rake
731
- class RDNPackageTask < TaskLib
732
- attr_accessor :targets
733
-
734
- def initialize(name, version, params={})
735
- @name = name
736
- @version = version
737
- @out_dir = params[:out_dir] || OUT_DIR
738
- @deps = params[:deps] || []
739
- @configuration = params[:configuration] || CONFIGURATION
740
- globs = params[:globs] || []
741
- @targets = FileList.new globs
742
-
743
- yield self if block_given?
744
- define
929
+ class RDNPackageTask < Rake::TaskLib
930
+ attr_accessor :targets
931
+
932
+ def initialize(name, params={})
933
+ @name = name
934
+ @out_dir = params[:out_dir] || OUT_DIR
935
+ @deps = params[:deps] || []
936
+ @configuration = params[:configuration] || CONFIGURATION
937
+ globs = params[:globs] || []
938
+ @targets = FileList.new globs
939
+
940
+ yield self if block_given?
941
+ define
942
+ end
943
+
944
+ def define
945
+ out_pkg = File.join(@out_dir, 'pkg')
946
+ out_pkg_name = File.join(out_pkg, @name)
947
+
948
+ directory out_pkg
949
+ directory out_pkg_name
950
+
951
+ @deps.each do |d|
952
+ task :package => d
745
953
  end
746
-
747
- def define
748
- pkg = File.join(@out_dir, 'pkg')
749
- pkg_root = renamed(File.join(pkg, @name))
750
-
751
- directory pkg
752
- directory pkg_root
753
-
754
- package_file = pkg_root + '.zip'
755
- package_file_regex = regexify(package_file)
756
-
757
- @deps.each do |d|
758
- file package_file => d
759
- task :package => d
760
- end
761
-
762
- rule(/#{package_file_regex}/) do |r|
763
- @targets.each do |t|
764
- f = Pathname.new(t)
765
- if f.directory?
766
- cp_r f, pkg_root
767
- else
768
- cp f, pkg_root
769
- end
770
- end
771
- snipped = pkg_root.sub(pkg + '/', '')
772
- sz = SevenZip.new(package_file)
773
- chdir pkg_root do
774
- sz.run_add
775
- end
776
- end
777
-
778
- directory @out_dir
779
-
780
- desc "Generate zip'd packages for all package-tasks"
781
- task :package => [@out_dir, pkg, pkg_root, package_file]
782
-
783
- desc "Generate zip'd package for #{@name}"
784
- task "package_#{@name}".to_sym => [@out_dir, pkg, pkg_root, package_file]
785
-
786
- desc "Delete all packages"
787
- task :clobber_package do
788
- rm_rf pkg
954
+
955
+ out_pkg_name_regex = RakeDotNet::regexify(out_pkg_name)
956
+
957
+ rule(/#{out_pkg_name_regex}-#{@configuration}-v\d+\.\d+\.\d+\.\d+\.zip/) do |r|
958
+ file_name = r.name.match(/(#{out_pkg_name_regex}).*/)[1].sub(out_pkg, '').sub('/','')
959
+ version = r.name.match(/.*v(\d+\.\d+\.\d+\.\d+)\.zip/)[1]
960
+ run_package(out_pkg, file_name, version)
961
+ end
962
+
963
+ directory @out_dir
964
+
965
+ desc "Generate zip'd packages for all package-tasks"
966
+ task :package => [@out_dir, out_pkg, out_pkg_name] do
967
+ version = Versioner.new.get
968
+ Rake::Task["#{out_pkg_name}-#{@configuration}-v#{version}.zip"].invoke
969
+ end
970
+
971
+ desc "Generate zip'd package for #{@name}"
972
+ task "package_#{@name}".to_sym => [@out_dir, out_pkg, out_pkg_name] do
973
+ version = Versioner.new.get
974
+ Rake::Task["#{out_pkg_name}-#{@configuration}-v#{version}.zip"].invoke
975
+ end
976
+
977
+ desc "Delete all packages"
978
+ task :clobber_package do
979
+ rm_rf out_pkg
980
+ end
981
+
982
+ task :clobber => :clobber_package
983
+
984
+ desc "Delete all packages and recreate them"
985
+ task :repackage => [:clobber_package, :package]
986
+
987
+ self
988
+ end
989
+
990
+ def run_package(root_dir, package_name, version)
991
+ assembly_dir = File.join(root_dir, package_name)
992
+ mkdir_p assembly_dir
993
+ @targets.each do |t|
994
+ f = Pathname.new(t)
995
+ if f.directory?
996
+ cp_r f, File.join(assembly_dir, "#{f.basename}-#{@configuration}-v#{version}")
997
+ else
998
+ cp f, assembly_dir
789
999
  end
790
-
791
- task :clobber => :clobber_package
792
-
793
- desc "Delete all packages and recreate them"
794
- task :repackage => [:clobber_package, :package]
795
-
796
- self
797
1000
  end
798
-
799
- def renamed(target)
800
- "#{target}-#{@configuration}-v#{@version}"
1001
+ versioned_assembly_dir = File.join(root_dir, "#{package_name}-#{@configuration}-v#{version}")
1002
+ mv assembly_dir, versioned_assembly_dir
1003
+ vzip = versioned_assembly_dir + '.zip'
1004
+ sz = SevenZipCmd.new(vzip)
1005
+ chdir versioned_assembly_dir do
1006
+ sz.run_add
801
1007
  end
802
1008
  end
803
1009
  end
804
1010
 
805
1011
 
806
- class SevenZip
1012
+ class SevenZipCmd
807
1013
  def initialize(archive_name, opts={})
808
1014
  arch = ENV['PROCESSOR_ARCHITECTURE'] || 'AMD64'
809
1015
  bin = arch == 'x86' ? '7za.exe' : '7z.exe'
810
1016
  @exe = opts[:sevenzip] || File.expand_path(File.join(TOOLS_DIR, '7zip', arch, bin))
811
1017
  @archive_name = File.expand_path(archive_name)
812
1018
  @params = opts
813
-
1019
+
814
1020
  yield self if block_given?
815
1021
  end
816
-
1022
+
817
1023
  def cmd_add
818
1024
  "#{exe} a #{archive_name} #{file_names}"
819
1025
  end
820
-
1026
+
821
1027
  def run_add
822
1028
  puts cmd_add if VERBOSE
823
1029
  sh cmd_add
824
1030
  end
825
-
1031
+
826
1032
  def cmd_extract
827
1033
  "#{exe} x -y #{out_dir} #{archive_name} #{file_names}"
828
1034
  end
829
-
1035
+
830
1036
  def run_extract
831
1037
  puts cmd_extract if VERBOSE
832
1038
  sh cmd_extract
833
1039
  end
834
-
1040
+
835
1041
  def out_dir
836
1042
  od = @params[:out_dir]
837
1043
  "-o#{File.expand_path(od)}" unless @params[:out_dir].nil?
838
1044
  end
839
-
1045
+
840
1046
  def archive_name
841
1047
  "\"#{@archive_name}\""
842
1048
  end
843
-
1049
+
844
1050
  def file_names
845
1051
  fns = @params[:file_names]
846
1052
  if fns.is_a? String
@@ -849,66 +1055,66 @@ class SevenZip
849
1055
  list = ''
850
1056
  fns.each do |fn|
851
1057
  list += "\"#{File.expand_path(fn)}\" "
852
- end
1058
+ end
853
1059
  list.chop
854
1060
  end
855
1061
  end
856
-
1062
+
857
1063
  def exe
858
1064
  "\"#{@exe}\""
859
1065
  end
860
1066
  end
861
1067
 
862
1068
 
863
- class Svn
864
- attr_accessor :svn
865
-
866
- def initialize(opts={})
867
- @svn = opts[:svn] || File.join(TOOLS_DIR, 'svn', 'bin', 'svn.exe')
868
- yield self if block_given?
1069
+ class SvnCmd < Cli
1070
+ def initialize(params={})
1071
+ sps = params[:search_paths] || []
1072
+ sps << File.join(TOOLS_DIR, 'svn', 'bin')
1073
+ sps << File.join(ENV['PROGRAMFILES'], 'subversion', 'bin')
1074
+ sps << File.join(ENV['PROGRAMFILES'], 'svn', 'bin')
1075
+ super(params.merge({:exe_name=>'svn.exe',:search_paths=>sps}))
869
1076
  end
870
-
871
- def exe
872
- "\"#{@svn}\""
1077
+
1078
+ def cmd
1079
+ return super
873
1080
  end
874
1081
  end
875
1082
 
876
- class SvnExport < Svn
877
- def initialize(src, dest, opts={})
878
- super(opts)
879
- @src = src
880
- @dest = dest
1083
+ class SvnExport < SvnCmd
1084
+ def initialize(params={})
1085
+ super
1086
+ raise(ArgumentError, "src parameter was missing", caller) if params[:src].nil?
1087
+ raise(ArgumentError, "dest parameter was missing", caller) if params[:dest].nil?
1088
+ @src = params[:src]
1089
+ @dest = params[:dest]
881
1090
  end
882
-
1091
+
1092
+ def src
1093
+ return "\"#{File.expand_path(@src)}\""
1094
+ end
1095
+
1096
+ def dest
1097
+ return "\"#{File.expand_path(@dest)}\""
1098
+ end
1099
+
883
1100
  def cmd
884
- "#{exe} export #{src} #{dest}"
1101
+ return "#{super} export #{src} #{dest}"
885
1102
  end
886
-
887
- def export
888
- puts cmd if VERBOSE
1103
+
1104
+ def run
1105
+ puts cmd if VERBOSE==true
889
1106
  sh cmd
890
1107
  end
891
-
892
- def src
893
- "\"#{@src}\""
894
- end
895
-
896
- def dest
897
- "\"#{@dest}\""
898
- end
899
1108
  end
900
1109
 
901
- class SvnInfo < Svn
902
- attr_accessor :svn
903
-
904
- def initialize(opts)
905
- super(opts)
906
- @path = opts[:path] || '.'
907
- yield self if block_given?
1110
+ class SvnInfo < SvnCmd
1111
+ def initialize(params={})
1112
+ super
1113
+ @path = params[:path] || '.'
908
1114
  end
909
-
1115
+
910
1116
  def cmd
911
- "#{exe} info #{path}"
1117
+ "#{super} info #{path}"
912
1118
  end
913
1119
 
914
1120
  def revision
@@ -916,7 +1122,7 @@ class SvnInfo < Svn
916
1122
  out = `#{cmd}`
917
1123
  out.match(/Revision: (\d+)/)[1]
918
1124
  end
919
-
1125
+
920
1126
  def path
921
1127
  "\"#{@path}\""
922
1128
  end
@@ -924,38 +1130,38 @@ end
924
1130
 
925
1131
 
926
1132
  class Versioner
927
- def initialize(template_file=nil, opts={})
928
- tf_path = template_file || 'version.template.txt'
929
- @tf = Pathname.new(tf_path)
930
- @vf = Pathname.new(tf_path.sub('.template', ''))
931
- end
932
-
933
- def get
934
- return @vf.read.chomp if @vf.exist?
935
-
936
- v = "#{maj_min}.#{build}.#{revision}"
937
- @vf.open('w') {|f| f.write(v) }
938
- return v
939
- end
940
-
941
- def maj_min
942
- return @tf.read.chomp
943
- end
944
-
945
- def build
946
- bn = ENV['BUILD_NUMBER']
947
- return 0 if bn == nil || !bn.match(/\d+/)
948
- return bn
949
- end
950
-
951
- def revision
952
- if (Pathname.new('.svn').exist?)
953
- return SvnInfo.new(:path => '.').revision
954
- else
955
- # TODO: return something numeric but sane for non-numeric revision numbers (eg DVCSs)
956
- return '0' # YYYYMMDD is actually invalid for a {revision} number.
957
- end
958
- end
1133
+ def initialize(template_file=nil, opts={})
1134
+ tf_path = template_file || 'version.template.txt'
1135
+ @tf = Pathname.new(tf_path)
1136
+ @vf = Pathname.new(tf_path.sub('.template', ''))
1137
+ end
1138
+
1139
+ def get
1140
+ return @vf.read.chomp if @vf.exist?
1141
+
1142
+ v = "#{maj_min}.#{build}.#{revision}"
1143
+ @vf.open('w') {|f| f.write(v) }
1144
+ return v
1145
+ end
1146
+
1147
+ def maj_min
1148
+ return @tf.read.chomp
1149
+ end
1150
+
1151
+ def build
1152
+ bn = ENV['BUILD_NUMBER']
1153
+ return 0 if bn == nil || !bn.match(/\d+/)
1154
+ return bn
1155
+ end
1156
+
1157
+ def revision
1158
+ if (Pathname.new('.svn').exist?)
1159
+ return SvnInfo.new(:path => '.').revision
1160
+ else
1161
+ # TODO: return something numeric but sane for non-numeric revision numbers (eg DVCSs)
1162
+ return '0' # YYYYMMDD is actually invalid for a {revision} number.
1163
+ end
1164
+ end
959
1165
  end
960
1166
 
961
1167
  Version_txt = 'version.txt'
@@ -966,65 +1172,63 @@ task :version => Version_txt
966
1172
  task :assembly_info => Version_txt
967
1173
 
968
1174
 
969
- module Rake
970
- class XUnitTask < TaskLib
971
- attr_accessor :suites_dir, :reports_dir, :options
1175
+ class XUnitTask < Rake::TaskLib
1176
+ attr_accessor :suites_dir, :reports_dir, :options
1177
+
1178
+ def initialize(params={}) # :yield: self
1179
+ @suites_dir = params[:suites_dir] || File.join(OUT_DIR, 'bin')
1180
+ @reports_dir = params[:reports_dir] || File.join(OUT_DIR, 'reports')
1181
+ @options = params[:options] || {}
1182
+ @deps = params[:deps] || []
972
1183
 
973
- def initialize(params={}) # :yield: self
974
- @suites_dir = params[:suites_dir] || File.join(OUT_DIR, "bin-#{CONFIGURATION}-v#{Versioner.new.get}")
975
- @reports_dir = params[:reports_dir] || File.join(OUT_DIR, 'reports')
976
- @options = params[:options] || {}
977
- @deps = params[:deps] || []
978
-
979
- yield self if block_given?
980
- define
1184
+ yield self if block_given?
1185
+ define
1186
+ end
1187
+
1188
+ # Create the tasks defined by this task lib.
1189
+ def define
1190
+ @deps.each do |d|
1191
+ task :xunit => d
981
1192
  end
982
1193
 
983
- # Create the tasks defined by this task lib.
984
- def define
985
- @deps.each do |d|
986
- task :xunit => d
987
- end
988
-
989
- rule(/#{@reports_dir}\/.*Tests.*\//) do |r|
990
- suite = r.name.match(/.*\/(.*Tests)\//)[1]
991
- testsDll = File.join(@suites_dir, suite + '.dll')
992
- out_dir = File.join(@reports_dir, suite)
993
- unless File.exist?(out_dir) && uptodate?(testsDll, out_dir)
994
- mkdir_p(out_dir) unless File.exist?(out_dir)
995
- x = XUnit.new(testsDll, out_dir, nil, options=@options)
996
- x.run
997
- end
1194
+ rule(/#{@reports_dir}\/.*Tests.*\//) do |r|
1195
+ suite = r.name.match(/.*\/(.*Tests)\//)[1]
1196
+ testsDll = File.join(@suites_dir, suite + '.dll')
1197
+ out_dir = File.join(@reports_dir, suite)
1198
+ unless File.exist?(out_dir) && uptodate?(testsDll, out_dir)
1199
+ mkdir_p(out_dir) unless File.exist?(out_dir)
1200
+ x = XUnitConsoleCmd.new(testsDll, out_dir, nil, options=@options)
1201
+ x.run
998
1202
  end
1203
+ end
999
1204
 
1000
- directory @reports_dir
1001
-
1002
- desc "Generate test reports (which ones, depends on the content of XUNIT_OPTS) inside of each directory specified, where each directory matches a test-suite name (give relative paths) (otherwise, all matching #{@suites_dir}/*Tests.*.dll) and write reports to #{@reports_dir}"
1003
- task :xunit,[:reports] => [@reports_dir] do |t, args|
1004
- reports_list = FileList.new("#{@suites_dir}/**/*Tests*.dll").pathmap("#{@reports_dir}/%n/")
1005
- args.with_defaults(:reports => reports_list)
1006
- args.reports.each do |r|
1007
- Rake::FileTask[r].invoke
1008
- end
1009
- end
1010
-
1011
- task :xunit_clobber do
1012
- rm_rf(@reports_dir)
1205
+ directory @reports_dir
1206
+
1207
+ desc "Generate test reports (which ones, depends on the content of XUNIT_OPTS) inside of each directory specified, where each directory matches a test-suite name (give relative paths) (otherwise, all matching #{@suites_dir}/*Tests.*.dll) and write reports to #{@reports_dir}"
1208
+ task :xunit, [:reports] => [@reports_dir] do |t, args|
1209
+ reports_list = FileList.new("#{@suites_dir}/**/*Tests*.dll").pathmap("#{@reports_dir}/%n/")
1210
+ args.with_defaults(:reports => reports_list)
1211
+ args.reports.each do |r|
1212
+ Rake::FileTask[r].invoke
1013
1213
  end
1014
-
1015
- self
1016
1214
  end
1215
+
1216
+ task :xunit_clobber do
1217
+ rm_rf(@reports_dir)
1218
+ end
1219
+
1220
+ self
1017
1221
  end
1018
1222
  end
1019
1223
 
1020
- class XUnit
1224
+ class XUnitConsoleCmd
1021
1225
  attr_accessor :xunit, :test_dll, :reports_dir, :options
1022
-
1226
+
1023
1227
  def initialize(test_dll, reports_dir, xunit=nil, options={})
1024
1228
  x86exe = File.join(TOOLS_DIR, 'xunit', 'xunit.console.x86.exe')
1025
1229
  x64exe = File.join(TOOLS_DIR, 'xunit', 'xunit.console.exe')
1026
1230
  path_to_xunit = x64exe
1027
- if File.exist? x86exe
1231
+ if File.exist? x86exe
1028
1232
  path_to_xunit = x86exe
1029
1233
  end
1030
1234
  @xunit = xunit || path_to_xunit
@@ -1033,7 +1237,7 @@ class XUnit
1033
1237
  @reports_dir = File.expand_path(reports_dir)
1034
1238
  @options = options
1035
1239
  end
1036
-
1240
+
1037
1241
  def run
1038
1242
  test_dir = Pathname.new(test_dll).dirname
1039
1243
  chdir test_dir do
@@ -1041,46 +1245,52 @@ class XUnit
1041
1245
  sh cmd
1042
1246
  end
1043
1247
  end
1044
-
1248
+
1045
1249
  def cmd
1046
1250
  cmd = "#{exe} #{test_dll} #{html} #{xml} #{nunit} #{wait} #{noshadow} #{teamcity}"
1047
1251
  end
1048
-
1252
+
1049
1253
  def exe
1050
1254
  "\"#{@xunit}\""
1051
1255
  end
1052
-
1256
+
1053
1257
  def suite
1054
1258
  @test_dll.match(/.*\/([\w\.]+)\.dll/)[1]
1055
1259
  end
1056
-
1260
+
1057
1261
  def test_dll
1058
- "\"#{@test_dll}\""
1262
+ "\"#{@test_dll}\"".gsub('/', '\\')
1059
1263
  end
1060
-
1264
+
1061
1265
  def html
1062
- "/html #{@reports_dir}/#{suite}.test-results.html" if @options.has_key?(:html)
1266
+ path = "#{@reports_dir}/#{suite}.test-results.html".gsub('/', '\\')
1267
+ "/html \"#{path}\"" if @options.has_key?(:html)
1063
1268
  end
1064
-
1269
+
1065
1270
  def xml
1066
- "/xml #{@reports_dir}/#{suite}.test-results.xml" if @options.has_key?(:xml)
1271
+ path = "#{@reports_dir}/#{suite}.test-results.xml".gsub('/', '\\')
1272
+ "/xml \"#{path}\"" if @options.has_key?(:xml)
1067
1273
  end
1068
-
1274
+
1069
1275
  def nunit
1070
- "/nunit #{@reports_dir}/#{suite}.test-results.nunit.xml" if @options.has_key?(:nunit)
1276
+ path = "#{@reports_dir}/#{suite}.test-results.nunit.xml".gsub('/', '\\')
1277
+ "/nunit \"#{path}\"" if @options.has_key?(:nunit)
1071
1278
  end
1072
1279
 
1073
1280
  def wait
1074
1281
  '/wait' if @options.has_key?(:wait)
1075
1282
  end
1076
-
1283
+
1077
1284
  def noshadow
1078
1285
  '/noshadow' if @options.has_key?(:noshadow)
1079
1286
  end
1080
-
1287
+
1081
1288
  def teamcity
1082
1289
  '/teamcity' if @options.has_key?(:teamcity)
1083
1290
  end
1084
1291
  end
1085
1292
 
1086
1293
 
1294
+ end
1295
+
1296
+