1
1
require 'fileutils'
2
+ require 'rexml/document'
3
+ require 'json'
2
4
require 'albacore'
3
- require './tools/albacore/nuspec_patch'
4
5
5
- NH_VERSION = '3.x'
6
+ PROPS = 'src/CommonAssemblyInfo.cs'
7
+ SLN = 'src/FluentNHibernate.sln'
8
+ CONFIG = 'config.json'
9
+ NUSPEC = 'src/FluentNHibernate.nuspec'
6
10
7
11
module Platform
8
12
@@ -24,62 +28,76 @@ module Platform
24
28
sw + arg
25
29
end
26
30
31
+ def self.config
32
+ JSON.parse(File.read(CONFIG))
33
+ end
34
+
27
35
end
28
36
37
+ NH_VERSION = Platform.config['build']['nh_precompiler_switch']
38
+
39
+ # Albacore.configure do |config|
40
+ # config.log_level = :verbose
41
+ # end
42
+
29
43
def get_version
30
- ENV['BUILD_NUMBER'] || '1.3.0.0'
44
+ ENV['BUILD_NUMBER'] || Platform.config['default_version_number']
31
45
end
32
46
33
- task :default => ' build:all'
47
+ task :default => ['ripple:restore', 'source:update_version', ' build:all']
34
48
35
49
namespace :ci do
36
- task :run_ci_build => [
37
- 'build:all',
38
- 'docs:build',
39
- 'package:all',
40
- ]
50
+ task :run_ci_build => ['ripple:restore', 'build:all', 'docs:build', 'package:all' ]
41
51
end
42
52
43
53
namespace :ripple do
44
- ripple = Platform.runtime("buildsupport/ripple.exe")
45
- args = "restore"
46
- sh "#{ripple} #{args}"
54
+ desc 'Restores NuGet package binaries'
55
+ task :restore do |cmd|
56
+ ripple = Platform.runtime("buildsupport/ripple.exe")
57
+ args = "restore"
58
+ sh "#{ripple} #{args}"
59
+ end
47
60
end
48
61
49
62
namespace :source do
50
63
desc 'Update assembly info with latest version number'
51
- assemblyinfo :update_version do |asm|
52
- asm.output_file = 'src/CommonAssemblyInfo.cs'
64
+ assemblyinfo :update_version do |info|
65
+ info.output_file = PROPS
66
+ commit_hash = `git log -1 --format="%H%"`
53
67
54
- asm.version = get_version
55
- asm.company_name = 'http://fluentnhibernate.org'
56
- asm.product_name = 'FluentNHibernate'
57
- asm.copyright = "Copyright 2008-#{Time.new.year} James Gregory and contributors (Paul Batum, Hudson Akridge et al). All rights reserved."
58
- asm.namespaces = ['System.Security']
59
- asm.custom_attributes :AllowPartiallyTrustedCallers => nil
68
+ info.title = Platform.config['assembly_info']['title']
69
+ info.version = get_version
70
+ info.informational_version = Platform.config['assembly_info']['version']
71
+ info.company_name = 'http://fluentnhibernate.org'
72
+ info.product_name = 'FluentNHibernate'
73
+ info.description = commit_hash[0..(commit_hash.length - 3)]
74
+ info.copyright = "Copyright 2008-#{Time.new.year} James Gregory and contributors (Paul Batum, Hudson Akridge et al). All rights reserved."
75
+ info.namespaces = ['System.Security']
60
76
61
- puts "The build number is #{asm .version}"
77
+ puts "The new version is #{info .version}"
62
78
end
63
79
64
80
task :nhibernate_version, :nhibernate_version do |t,args|
65
81
args.with_defaults :nhibernate_version => ENV['nhibernate_version'] || NH_VERSION
66
82
end
67
83
68
84
desc 'Compile the source'
69
- msbuild :compile, [:nhibernate_version] => :nhibernate_version do |msb, args|
85
+ msbuild :compile, [:nhibernate_version] => :nhibernate_version do |msbuild, args|
70
86
args.with_defaults :nhibernate_version => ENV['nhibernate_version'] || NH_VERSION
71
87
72
88
nh_version_precompiler_switch = 'NH' + args.nhibernate_version.gsub('.', '')
73
89
74
- puts nh_version_precompiler_switch
90
+ puts 'Precompiler switch: ' + nh_version_precompiler_switch
75
91
76
- msb .properties = {
92
+ msbuild .properties = {
77
93
configuration: :Release,
78
94
DefineConstants: nh_version_precompiler_switch,
79
- WarningLevel: 0,
95
+ WarningLevel: 0
80
96
}
81
- msb.targets [:Clean, :Build]
82
- msb.solution = 'src/FluentNHibernate.sln'
97
+ msbuild.targets [:Clean, :Build]
98
+ msbuild.solution = SLN
99
+ msbuild.verbosity = :minimal
100
+ msbuild.parameters = ["/p:TargetFrameworkVersion=#{Platform.config['build']['msbuild_runtime']}"]
83
101
end
84
102
end
85
103
@@ -89,14 +107,15 @@ namespace :specs do
89
107
90
108
desc 'Run MSpec specs'
91
109
mspec :mspec do |mspec|
92
- mspec.command = ' src/packages/Machine.Specifications.0.5.15/tools/mspec.exe'
93
- mspec.assemblies 'src/FluentNHibernate.Specs/bin/Release/FluentNHibernate.Specs.dll'
110
+ mspec.command = " src/packages/Machine.Specifications.0.5.15/tools/mspec#{Platform.config['tests']['mspec_exec_suffix']}.exe"
111
+ mspec.assemblies = [ 'src/FluentNHibernate.Specs/bin/Release/FluentNHibernate.Specs.dll' ]
94
112
end
95
113
96
114
desc 'Run NUnit tests'
97
115
nunit :nunit do |nunit|
98
116
nunit.command = 'src/packages/NUnit.2.5.7.10213/Tools/nunit-console-x86.exe'
99
- nunit.assemblies 'src/FluentNHibernate.Testing/bin/Release/FluentNHibernate.Testing.dll'
117
+ nunit.assemblies = [ 'src/FluentNHibernate.Testing/bin/Release/FluentNHibernate.Testing.dll' ]
118
+ nunit.parameters = [ "/framework:#{Platform.config['tests']['nunit_framework_runtime']}" ]
100
119
end
101
120
end
102
121
@@ -117,7 +136,28 @@ namespace :docs do
117
136
desc 'Create API docs'
118
137
docu :build do |d|
119
138
d.command = 'tools/docu/docu.exe'
120
- d.assemblies 'build/FluentNHibernate.dll'
139
+ d.assemblies = [ 'build/FluentNHibernate.dll' ]
140
+ end
141
+ end
142
+
143
+ namespace :git do
144
+ desc "Tags the current release"
145
+ task :tag, :assembly_info do |asm, args|
146
+ args.with_defaults(:assembly_info => Platform.config['assembly_info']['version'])
147
+
148
+ sh "git tag \"v#{args.version}\""
149
+ end
150
+
151
+ desc "Updates the version and tags the release"
152
+ task :prep_release, :assembly_info do |task, args|
153
+ if !args.version.nil?
154
+ task(:update_version).invoke(args.version)
155
+
156
+ sh "git add #{CONFIG} #{NUSPEC}"
157
+ sh "git commit -m \"Updated version to #{args.version}\""
158
+
159
+ task(:tag).invoke(args.version)
160
+ end
121
161
end
122
162
end
123
163
@@ -159,39 +199,62 @@ namespace :package do
159
199
zip.output_path = 'dist'
160
200
end
161
201
162
- nuspec do |nu|
163
- nu.id = 'FluentNHibernate'
164
- nu.version = get_version()
165
- nu.authors = 'James Gregory and contributors'
166
- nu.description = 'Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate.'
167
- nu.title = 'Fluent NHibernate'
168
- nu.language = 'en-US'
169
- nu.licenseUrl = 'http://github.com/jagregory/fluent-nhibernate/raw/master/LICENSE.txt'
170
- nu.projectUrl = 'http://fluentnhibernate.org'
171
- nu.dependency 'NHibernate', '[3.3.1.4000,4.0)'
172
- nu.working_directory = 'build'
173
- nu.output_file = 'fluentnhibernate.nuspec'
174
- nu.file 'FluentNHibernate.dll', 'lib'
175
- nu.file 'FluentNHibernate.xml', 'lib'
176
- nu.tags = 'orm dal nhibernate conventions'
177
- end
178
-
179
- nugetpack do |nu|
202
+ task :nuspec do |nu|
203
+ config = Platform.config['nuspec']
204
+
205
+ puts "Updating #{NUSPEC}"
206
+ update_xml NUSPEC do |xml|
207
+ xml.root.elements["metadata/id"].text = config['id']
208
+ xml.root.elements["metadata/title"].text = config['title']
209
+ xml.root.elements["metadata/version"].text = config['version']
210
+
211
+ xml.root.elements["metadata/dependencies/dependency[@id='NHibernate']"].attributes['version'] = config['nhibernate_version_interval']
212
+
213
+ xml.root.elements["metadata/authors"].text = "James Gregory and contributors"
214
+ xml.root.elements["metadata/owners"].text = "jagregory, chester89"
215
+ xml.root.elements["metadata/language"].text = "en-US"
216
+ xml.root.elements["metadata/description"].text = "Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate."
217
+ xml.root.elements["metadata/licenseUrl"].text = "http://github.com/jagregory/fluent-nhibernate/raw/master/LICENSE.txt"
218
+ xml.root.elements["metadata/projectUrl"].text = "http://fluentnhibernate.org"
219
+ xml.root.elements["metadata/tags"].text = "orm dal nhibernate conventions"
220
+
221
+ xml.root.elements["files/file[contains(@src, 'bin\\Release\\FluentNHibernate.*')]"].attributes['target'] = "lib\\#{config['binaries_folder']}"
222
+ end
223
+ end
224
+
225
+ nugetpack :nupack do |nu|
180
226
nu.command = 'tools/nuget/NuGet.exe'
181
- nu.nuspec = 'build/fluentnhibernate.nuspec'
182
- nu.base_folder = 'build '
227
+ nu.nuspec = NUSPEC
228
+ nu.base_folder = 'Release '
183
229
nu.output = 'dist'
184
230
end
185
231
186
232
desc 'Create nuget spec and package'
187
- task :nuget => [:nuspec, :nugetpack ]
233
+ task :nuget => [:nuspec, :nupack ]
188
234
189
235
desc 'Package everything (src, bin, docs, nuget)'
190
236
task :all => [:source, :binaries, :docs, :nuget]
191
237
end
192
238
239
+ def update_xml(xml_path)
240
+ #Open up the xml file
241
+ xml_file = File.new(xml_path)
242
+ xml = REXML::Document.new xml_file
243
+
244
+ #Allow caller to make the changes
245
+ yield xml
246
+
247
+ xml_file.close
248
+
249
+ #Save the changes
250
+ xml_file = File.open(xml_path, "w")
251
+ formatter = REXML::Formatters::Default.new(5)
252
+ formatter.write(xml, xml_file)
253
+ xml_file.close
254
+ end
255
+
193
256
task :sln do
194
257
Thread.new do
195
- system "devenv src/FluentNHibernate.sln "
258
+ system "devenv #{SLN} "
196
259
end
197
- end
260
+ end
0 commit comments