Skip to content

Commit 754cce8

Browse files
committed
Merge pull request #281 from chester89/migrateTo40
Migration to .NET 4.0 and NHibernate v4
2 parents 7a2c7bf + f56b2d5 commit 754cce8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+256
-474
lines changed

.gitignore

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
**/*.suo
22
**/*.user
33
**/*.sln*
4-
bin
5-
obj
64
_ReSharper*
7-
dist
8-
output
9-
build
105

116
*.DotSettings.user
127
*.csproj.user
13-
src/packages
14-
158
*.resharper.user
169
*.resharper
1710

@@ -23,7 +16,14 @@ src/packages
2316
*.ncrunchproject
2417
*.swp
2518
TestResult.xml
19+
Gemfile.lock
2620

27-
TestResult.xml
28-
build/
29-
*.nupkg
21+
src/packages
22+
bin
23+
obj
24+
dist
25+
output
26+
build
27+
*.nupkg
28+
logs/
29+
src/CommonAssemblyInfo.cs

.svn-authors

Lines changed: 0 additions & 11 deletions
This file was deleted.

Gemfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
source 'https://rubygems.org'
22

3-
gem 'rake'
4-
gem 'albacore'
3+
source 'https://rubygems.org'
4+
gem 'rake', '~>10.3.2'
5+
gem 'albacore', '1.0.0.rc2'

Gemfile.lock

Lines changed: 0 additions & 15 deletions
This file was deleted.

RakeFile

Lines changed: 117 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
require 'fileutils'
2+
require 'rexml/document'
3+
require 'json'
24
require 'albacore'
3-
require './tools/albacore/nuspec_patch'
45

5-
NH_VERSION = '3.x'
6+
PROPS = 'src/CommonAssemblyInfo.cs'
7+
SLN = 'src/FluentNHibernate.sln'
8+
CONFIG = 'config.json'
9+
NUSPEC = 'src/FluentNHibernate.nuspec'
610

711
module Platform
812

@@ -24,62 +28,76 @@ module Platform
2428
sw + arg
2529
end
2630

31+
def self.config
32+
JSON.parse(File.read(CONFIG))
33+
end
34+
2735
end
2836

37+
NH_VERSION = Platform.config['build']['nh_precompiler_switch']
38+
39+
# Albacore.configure do |config|
40+
# config.log_level = :verbose
41+
# end
42+
2943
def get_version
30-
ENV['BUILD_NUMBER'] || '1.3.0.0'
44+
ENV['BUILD_NUMBER'] || Platform.config['default_version_number']
3145
end
3246

33-
task :default => 'build:all'
47+
task :default => ['ripple:restore', 'source:update_version', 'build:all']
3448

3549
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' ]
4151
end
4252

4353
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
4760
end
4861

4962
namespace :source do
5063
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%"`
5367

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']
6076

61-
puts "The build number is #{asm.version}"
77+
puts "The new version is #{info.version}"
6278
end
6379

6480
task :nhibernate_version, :nhibernate_version do |t,args|
6581
args.with_defaults :nhibernate_version => ENV['nhibernate_version'] || NH_VERSION
6682
end
6783

6884
desc 'Compile the source'
69-
msbuild :compile, [:nhibernate_version] => :nhibernate_version do |msb,args|
85+
msbuild :compile, [:nhibernate_version] => :nhibernate_version do |msbuild, args|
7086
args.with_defaults :nhibernate_version => ENV['nhibernate_version'] || NH_VERSION
7187

7288
nh_version_precompiler_switch = 'NH' + args.nhibernate_version.gsub('.', '')
7389

74-
puts nh_version_precompiler_switch
90+
puts 'Precompiler switch: ' + nh_version_precompiler_switch
7591

76-
msb.properties = {
92+
msbuild.properties = {
7793
configuration: :Release,
7894
DefineConstants: nh_version_precompiler_switch,
79-
WarningLevel: 0,
95+
WarningLevel: 0
8096
}
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']}"]
83101
end
84102
end
85103

@@ -89,14 +107,15 @@ namespace :specs do
89107

90108
desc 'Run MSpec specs'
91109
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' ]
94112
end
95113

96114
desc 'Run NUnit tests'
97115
nunit :nunit do |nunit|
98116
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']}" ]
100119
end
101120
end
102121

@@ -117,7 +136,28 @@ namespace :docs do
117136
desc 'Create API docs'
118137
docu :build do |d|
119138
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
121161
end
122162
end
123163

@@ -159,39 +199,62 @@ namespace :package do
159199
zip.output_path = 'dist'
160200
end
161201

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|
180226
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'
183229
nu.output = 'dist'
184230
end
185231

186232
desc 'Create nuget spec and package'
187-
task :nuget => [:nuspec, :nugetpack]
233+
task :nuget => [:nuspec, :nupack]
188234

189235
desc 'Package everything (src, bin, docs, nuget)'
190236
task :all => [:source, :binaries, :docs, :nuget]
191237
end
192238

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+
193256
task :sln do
194257
Thread.new do
195-
system "devenv src/FluentNHibernate.sln"
258+
system "devenv #{SLN}"
196259
end
197-
end
260+
end

0 commit comments

Comments
 (0)