This repository has been archived by the owner on Nov 14, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
BuildUtils.rb
executable file
·94 lines (72 loc) · 2.57 KB
/
BuildUtils.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
require 'erb'
class NUnitRunner
include FileTest
def initialize(paths)
@sourceDir = paths.fetch(:source, 'src')
@nunitDir = paths.fetch(:nunit, 'tools\\nunit')
@resultsDir = paths.fetch(:results, 'results')
@compileTarget = paths.fetch(:compilemode, 'debug')
end
def executeTests(assemblies)
Dir.mkdir @resultsDir #unless exists?(@resultsDir)
assemblies.each do |assem|
file = File.expand_path("#{@sourceDir}/#{assem}/bin/#{@compileTarget}/#{assem}.dll")
sh "#{@nunitDir}\\nunit-console.exe #{file} /nothread /xml=#{@resultsDir}\\#{assem}.dll-results.xml"
end
end
end
class MonoNUnitRunner
def initialize(paths)
@sourceDir = paths.fetch(:source, 'src')
@resultsDir = paths.fetch(:results, 'results')
@compileTarget = paths.fetch(:compilemode, 'debug')
end
def executeTests(assemblies)
assemblies.each do |assem|
file = File.expand_path("#{@sourceDir}/#{assem}/bin/#{@compileTarget}/#{assem}.dll")
sh "nunit-console2 #{file} -nothread -xml=#{@resultsDir}/#{assem}.dll-results.xml"
end
end
end
class MSBuildRunner
def self.compile(attributes)
version = attributes.fetch(:clrversion, 'v3.5')
compileTarget = attributes.fetch(:compilemode, 'debug')
solutionFile = attributes[:solutionfile]
frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', 'v3.5')
msbuildFile = File.join(frameworkDir, 'msbuild.exe')
sh "#{msbuildFile} #{solutionFile} /property:Configuration=#{compileTarget} /t:Rebuild"
end
end
class XBuildRunner
def self.compile(attributes)
version = attributes.fetch(:clrversion, 'v3.5')
compileTarget = attributes.fetch(:compilemode, 'debug')
solutionFile = attributes[:solutionfile]
#frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', 'v3.5')
#msbuildFile = File.join(frameworkDir, 'msbuild.exe')
sh "xbuild #{solutionFile} /property:Configuration=#{compileTarget} /t:Rebuild"
end
end
class AsmInfoBuilder
attr_reader :buildnumber
def initialize(baseVersion, properties)
@properties = properties;
@buildnumber = baseVersion;
@properties['Version'] = @properties['InformationalVersion'] = buildnumber;
end
def write(file)
template = %q{
using System;
using System.Reflection;
using System.Runtime.InteropServices;
<% @properties.each {|k, v| %>
[assembly: Assembly<%=k%>Attribute("<%=v%>")]
<% } %>
}.gsub(/^ /, '')
erb = ERB.new(template, 0, "%<>")
File.open(file, 'w') do |file|
file.puts erb.result(binding)
end
end
end