This repository has been archived by the owner on Sep 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
rakefile.rb
209 lines (179 loc) · 8.53 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
COPYRIGHT = "Copyright 2013 Chris Patterson"
require File.dirname(__FILE__) + "/build_support/BuildUtils.rb"
require File.dirname(__FILE__) + "/build_support/util.rb"
include FileTest
require 'albacore'
require File.dirname(__FILE__) + "/build_support/versioning.rb"
PRODUCT = 'MassTransit.Courier'
CLR_TOOLS_VERSION = 'v4.0.30319'
OUTPUT_PATH = 'bin/Release'
props = {
:src => File.expand_path("src"),
:nuget => File.join(File.expand_path("src"), ".nuget", "nuget.exe"),
:output => File.expand_path("build_output"),
:artifacts => File.expand_path("build_artifacts"),
:lib => File.expand_path("lib"),
:projects => ["MassTransit.Courier"],
:keyfile => File.expand_path("MassTransit.snk")
}
desc "Cleans, compiles, il-merges, unit tests, prepares examples, packages zip"
task :all => [:default, :package]
desc "**Default**, compiles and runs tests"
task :default => [:clean, :nuget_restore, :compile, :package]
desc "Update the common version information for the build. You can call this task without building."
assemblyinfo :global_version do |asm|
# Assembly file config
asm.product_name = PRODUCT
asm.description = "A MassTransit Routing Slip pattern implementation"
asm.version = FORMAL_VERSION
asm.file_version = FORMAL_VERSION
asm.custom_attributes :AssemblyInformationalVersion => "#{BUILD_VERSION}",
:ComVisibleAttribute => false,
:CLSCompliantAttribute => true
asm.copyright = COPYRIGHT
asm.output_file = 'src/SolutionVersion.cs'
asm.namespaces "System", "System.Reflection", "System.Runtime.InteropServices"
end
desc "Prepares the working directory for a new build"
task :clean do
FileUtils.rm_rf props[:output]
waitfor { !exists?(props[:output]) }
FileUtils.rm_rf props[:artifacts]
waitfor { !exists?(props[:artifacts]) }
Dir.mkdir props[:output]
Dir.mkdir props[:artifacts]
end
desc "Cleans, versions, compiles the application and generates build_output/."
task :compile => [:versioning, :global_version, :build4, :tests4, :copy4]
task :copy4 => [:build4] do
copyOutputFiles File.join(props[:src], "MassTransit.Courier/bin/Release"), "MassTransit.Courier.{dll,pdb,xml}", File.join(props[:output], 'net-4.0-full')
copyOutputFiles File.join(props[:src], "MassTransit.Courier.MongoDbIntegration/bin/Release"), "MassTransit.Courier.MongoDbIntegration.{dll,pdb,xml}", File.join(props[:output], 'net-4.0-full')
end
desc "Only compiles the application."
msbuild :build4 do |msb|
msb.properties :Configuration => "Release",
:Platform => 'Any CPU'
msb.use :net4
msb.targets :Rebuild
msb.properties[:SignAssembly] = 'true'
msb.properties[:AssemblyOriginatorKeyFile] = props[:keyfile]
msb.solution = 'src/MassTransit.Courier.sln'
end
def copyOutputFiles(fromDir, filePattern, outDir)
FileUtils.mkdir_p outDir unless exists?(outDir)
Dir.glob(File.join(fromDir, filePattern)){|file|
copy(file, outDir) if File.file?(file)
}
end
desc "Runs unit tests"
nunit :tests4 => [:build4] do |nunit|
nunit.command = File.join('src', 'packages','NUnit.Runners.2.6.3', 'tools', 'nunit-console.exe')
nunit.parameters = "/framework=#{CLR_TOOLS_VERSION}", '/nothread', '/exclude:Integration', '/nologo', '/labels', "\"/xml=#{File.join(props[:artifacts], 'nunit-test-results-net-4.0.xml')}\""
nunit.assemblies = FileList[File.join(props[:src], "MassTransit.Courier.Tests/bin/Release", "MassTransit.Courier.Tests.dll")]
end
task :package => [:nuget, :zip_output]
desc "ZIPs up the build results."
zip :zip_output => [:versioning] do |zip|
zip.directories_to_zip = [props[:output]]
zip.output_file = "MassTransit.Courier-#{NUGET_VERSION}.zip"
zip.output_path = props[:artifacts]
end
desc "restores missing packages"
msbuild :nuget_restore do |msb|
msb.use :net4
msb.targets :RestorePackages
msb.solution = File.join(props[:src], "MassTransit.Courier", "MassTransit.Courier.csproj")
end
desc "restores missing packages"
msbuild :nuget_restore do |msb|
msb.use :net4
msb.targets :RestorePackages
msb.solution = File.join(props[:src], "MassTransit.Courier.Tests", "MassTransit.Courier.Tests.csproj")
end
desc "restores missing packages"
msbuild :nuget_restore do |msb|
msb.use :net4
msb.targets :RestorePackages
msb.solution = File.join(props[:src], "MassTransit.Courier.MongoDbIntegration", "MassTransit.Courier.MongoDbIntegration.csproj")
end
desc "restores missing packages"
msbuild :nuget_restore do |msb|
msb.use :net4
msb.targets :RestorePackages
msb.solution = File.join(props[:src], "MassTransit.Courier.MongoDbIntegration.Tests", "MassTransit.Courier.MongoDbIntegration.Tests.csproj")
end
desc "Builds the nuget package"
task :nuget => [:versioning, :create_nuspec] do
sh "#{props[:nuget]} pack #{props[:artifacts]}/MassTransit.Courier.nuspec /Symbols /OutputDirectory #{props[:artifacts]}"
sh "#{props[:nuget]} pack #{props[:artifacts]}/MassTransit.Courier.MongoDbIntegration.nuspec /Symbols /OutputDirectory #{props[:artifacts]}"
end
nuspec :create_nuspec do |nuspec|
nuspec.id = 'MassTransit.Courier'
nuspec.version = NUGET_VERSION
nuspec.authors = 'Chris Patterson'
nuspec.summary = 'A MassTransit Routing Slip pattern implementation'
nuspec.description = 'An implementation of the routing slip pattern (EIP: Routing Slip), including activity execution and compensation, for MassTransit.'
nuspec.title = 'MassTransit.Courier'
nuspec.projectUrl = 'http://github.com/MassTransit/MassTransit.Courier'
nuspec.language = "en-US"
nuspec.licenseUrl = "http://www.apache.org/licenses/LICENSE-2.0"
nuspec.requireLicenseAcceptance = "false"
nuspec.iconUrl = 'https://a248.e.akamai.net/camo.github.com/72cb54409c345c49a1a2cda30498dfc78895f476/687474703a2f2f7777772e70686174626f79672e636f6d2f6d742d6c6f676f2e706e67'
nuspec.dependency "Magnum", "2.1.3"
nuspec.dependency "MassTransit", "2.10.2"
nuspec.dependency "Newtonsoft.Json", "6.0.6"
nuspec.output_file = File.join(props[:artifacts], 'MassTransit.Courier.nuspec')
add_files File.join(props[:output]), 'MassTransit.Courier.{dll,pdb,xml}', nuspec
nuspec.file(File.join(props[:src], "MassTransit.Courier\\**\\*.cs").gsub("/","\\"), "src")
end
nuspec :create_nuspec do |nuspec|
nuspec.id = 'MassTransit.Courier.MongoDbIntegration'
nuspec.version = NUGET_VERSION
nuspec.authors = 'Chris Patterson'
nuspec.summary = 'MassTransit Courier (Routing Slip) event storage using MongoDB'
nuspec.description = 'An event storage library for MongoDB to capture routing slip events generated by MassTransit.Courier'
nuspec.title = 'MassTransit.Courier.MongoDbIntegration'
nuspec.projectUrl = 'http://github.com/MassTransit/MassTransit.Courier'
nuspec.language = "en-US"
nuspec.licenseUrl = "http://www.apache.org/licenses/LICENSE-2.0"
nuspec.requireLicenseAcceptance = "false"
nuspec.iconUrl = 'https://a248.e.akamai.net/camo.github.com/72cb54409c345c49a1a2cda30498dfc78895f476/687474703a2f2f7777772e70686174626f79672e636f6d2f6d742d6c6f676f2e706e67'
nuspec.dependency "Magnum", "2.1.3"
nuspec.dependency "MassTransit", "2.10.2"
nuspec.dependency "MassTransit.Courier", NUGET_VERSION
nuspec.dependency "mongocsharpdriver", "1.9.2"
nuspec.output_file = File.join(props[:artifacts], 'MassTransit.Courier.MongoDbIntegration.nuspec')
add_files File.join(props[:output]), 'MassTransit.Courier.MongoDbIntegration.{dll,pdb,xml}', nuspec
nuspec.file(File.join(props[:src], "MassTransit.Courier.MongoDbIntegration\\**\\*.cs").gsub("/","\\"), "src")
end
def project_outputs(props)
props[:projects].map{ |p| "src/#{p}/bin/#{BUILD_CONFIG}/#{p}.dll" }.
concat( props[:projects].map{ |p| "src/#{p}/bin/#{BUILD_CONFIG}/#{p}.exe" } ).
find_all{ |path| exists?(path) }
end
def get_commit_hash_and_date
begin
commit = `git log -1 --pretty=format:%H`
git_date = `git log -1 --date=iso --pretty=format:%ad`
commit_date = DateTime.parse( git_date ).strftime("%Y-%m-%d %H%M%S")
rescue
commit = "git unavailable"
end
[commit, commit_date]
end
def add_files stage, what_dlls, nuspec
[['net35', 'net-3.5'], ['net40', 'net-4.0'], ['net40-full', 'net-4.0-full']].each{|fw|
takeFrom = File.join(stage, fw[1], what_dlls)
Dir.glob(takeFrom).each do |f|
nuspec.file(f.gsub("/", "\\"), "lib\\#{fw[0]}")
end
}
end
def waitfor(&block)
checks = 0
until block.call || checks >10
sleep 0.5
checks += 1
end
raise 'Waitfor timeout expired. Make sure that you aren\'t running something from the build output folders, or that you have browsed to it through Explorer.' if checks > 10
end