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'
6
9
7
10
module Platform
8
11
@@ -24,13 +27,24 @@ module Platform
24
27
sw + arg
25
28
end
26
29
30
+ def self.config
31
+ JSON.parse(File.read(CONFIG))
32
+ end
33
+
27
34
end
28
35
36
+ NH_VERSION = Platform.config['build']['nh_precompiler_switch']
37
+ NUSPEC = Platform.config['nuspec']['filename']
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
50
task :run_ci_build => [
@@ -41,45 +55,52 @@ namespace :ci do
41
55
end
42
56
43
57
namespace :ripple do
44
- ripple = Platform.runtime("buildsupport/ripple.exe")
45
- args = "restore"
46
- sh "#{ripple} #{args}"
58
+ desc 'Restores NuGet package binaries'
59
+ task :restore do |cmd|
60
+ ripple = Platform.runtime("buildsupport/ripple.exe")
61
+ args = "restore"
62
+ sh "#{ripple} #{args}"
63
+ end
47
64
end
48
65
49
66
namespace :source do
50
67
desc 'Update assembly info with latest version number'
51
- assemblyinfo :update_version do |asm|
52
- asm.output_file = 'src/CommonAssemblyInfo.cs'
68
+ assemblyinfo :update_version do |info|
69
+ info.output_file = PROPS
70
+
71
+ commit_hash = `git log -1 --format="%H%"`
53
72
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
73
+ info .version = info.file_version = get_version
74
+ info .company_name = 'http://fluentnhibernate.org'
75
+ info .product_name = 'FluentNHibernate'
76
+ info.description = commit_hash[0..(commit_hash.length - 3)]
77
+ info.copyright = "Copyright 2008-#{Time.new.year} James Gregory and contributors (Paul Batum, Hudson Akridge et al). All rights reserved."
78
+ info.namespaces = ['System.Security']
60
79
61
- puts "The build number is #{asm .version}"
80
+ puts "The new build number is #{info .version}"
62
81
end
63
82
64
83
task :nhibernate_version, :nhibernate_version do |t,args|
65
84
args.with_defaults :nhibernate_version => ENV['nhibernate_version'] || NH_VERSION
66
85
end
67
86
68
87
desc 'Compile the source'
69
- msbuild :compile, [:nhibernate_version] => :nhibernate_version do |msb, args|
88
+ msbuild :compile, [:nhibernate_version] => :nhibernate_version do |msbuild, args|
70
89
args.with_defaults :nhibernate_version => ENV['nhibernate_version'] || NH_VERSION
71
90
72
91
nh_version_precompiler_switch = 'NH' + args.nhibernate_version.gsub('.', '')
73
92
74
- puts nh_version_precompiler_switch
93
+ puts 'Precompiler switch: ' + nh_version_precompiler_switch
75
94
76
- msb .properties = {
95
+ msbuild .properties = {
77
96
configuration: :Release,
78
97
DefineConstants: nh_version_precompiler_switch,
79
- WarningLevel: 0,
98
+ WarningLevel: 0
80
99
}
81
- msb.targets [:Clean, :Build]
82
- msb.solution = 'src/FluentNHibernate.sln'
100
+ msbuild.targets [:Clean, :Build]
101
+ msbuild.solution = SLN
102
+ msbuild.verbosity = :minimal
103
+ msbuild.parameters = ["/p:TargetFrameworkVersion=#{Platform.config['build']['msbuild_runtime']}"]
83
104
end
84
105
end
85
106
@@ -89,14 +110,15 @@ namespace :specs do
89
110
90
111
desc 'Run MSpec specs'
91
112
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'
113
+ mspec.command = " src/packages/Machine.Specifications.0.5.15/tools/mspec#{Platform.config['tests']['mspec_exec_suffix']}.exe"
114
+ mspec.assemblies = [ 'src/FluentNHibernate.Specs/bin/Release/FluentNHibernate.Specs.dll' ]
94
115
end
95
116
96
117
desc 'Run NUnit tests'
97
118
nunit :nunit do |nunit|
98
119
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'
120
+ nunit.assemblies = [ 'src/FluentNHibernate.Testing/bin/Release/FluentNHibernate.Testing.dll' ]
121
+ nunit.parameters = [ "/framework:#{Platform.config['tests']['nunit_framework_runtime']}" ]
100
122
end
101
123
end
102
124
@@ -117,7 +139,7 @@ namespace :docs do
117
139
desc 'Create API docs'
118
140
docu :build do |d|
119
141
d.command = 'tools/docu/docu.exe'
120
- d.assemblies 'build/FluentNHibernate.dll'
142
+ d.assemblies = [ 'build/FluentNHibernate.dll' ]
121
143
end
122
144
end
123
145
@@ -159,39 +181,61 @@ namespace :package do
159
181
zip.output_path = 'dist'
160
182
end
161
183
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|
184
+ task :nuspec do |nu|
185
+ config = Platform.config['nuspec']
186
+
187
+ puts "Updating #{NUSPEC}"
188
+ update_xml NUSPEC do |xml|
189
+ # Override the version number in the nuspec file with the one from this rake file (set above)
190
+ xml.root.elements["metadata/version"].text = get_version
191
+
192
+ xml.root.elements["metadata/dependencies/dependency[@id='NHibernate']"].attributes['version'] = config['nhibernate_version_interval']
193
+
194
+ xml.root.elements["metadata/authors"].text = "James Gregory and contributors"
195
+ xml.root.elements["metadata/owners"].text = "jagregory, chester89"
196
+ xml.root.elements["metadata/language"].text = "en-US"
197
+ xml.root.elements["metadata/description"].text = "Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate."
198
+ xml.root.elements["metadata/licenseUrl"].text = "http://github.com/jagregory/fluent-nhibernate/raw/master/LICENSE.txt"
199
+ xml.root.elements["metadata/projectUrl"].text = "http://fluentnhibernate.org"
200
+ xml.root.elements["metadata/tags"].text = "orm dal nhibernate conventions"
201
+
202
+ xml.root.elements["files/file[contains(@src, 'bin\\Release\\FluentNHibernate.*')]"].attributes['target'] = "lib\\#{config['binaries_folder']}"
203
+ end
204
+ end
205
+
206
+ nugetpack :nupack do |nu|
180
207
nu.command = 'tools/nuget/NuGet.exe'
181
- nu.nuspec = 'build/fluentnhibernate.nuspec'
182
- nu.base_folder = 'build '
208
+ nu.nuspec = NUSPEC
209
+ nu.base_folder = 'Release '
183
210
nu.output = 'dist'
184
211
end
185
212
186
213
desc 'Create nuget spec and package'
187
- task :nuget => [:nuspec, :nugetpack ]
214
+ task :nuget => [:nuspec, :nupack ]
188
215
189
216
desc 'Package everything (src, bin, docs, nuget)'
190
217
task :all => [:source, :binaries, :docs, :nuget]
191
218
end
192
219
220
+ def update_xml(xml_path)
221
+ #Open up the xml file
222
+ xml_file = File.new(xml_path)
223
+ xml = REXML::Document.new xml_file
224
+
225
+ #Allow caller to make the changes
226
+ yield xml
227
+
228
+ xml_file.close
229
+
230
+ #Save the changes
231
+ xml_file = File.open(xml_path, "w")
232
+ formatter = REXML::Formatters::Default.new(5)
233
+ formatter.write(xml, xml_file)
234
+ xml_file.close
235
+ end
236
+
193
237
task :sln do
194
238
Thread.new do
195
- system "devenv src/FluentNHibernate.sln "
239
+ system "devenv #{SLN} "
196
240
end
197
- end
241
+ end
0 commit comments