Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 172 lines (150 sloc) 5.577 kB
2ac941f @shashankshetty update rakefile
shashankshetty authored
1 require 'albacore'
56c8cf4 @handcraftsman autoconvert newlines
handcraftsman authored
2
870995d @wbinford Standardized build and updated README.md
wbinford authored
3 PRODUCT_NAME = "FluentWebControls"
f2756c8 @handcraftsman update libraries to 4.5; change framework to 4.5; fix resharper 8 issues
handcraftsman authored
4 CLR_TOOLS_VERSION = "v4.0"
870995d @wbinford Standardized build and updated README.md
wbinford authored
5 DEFAULT_BUILD_NUMBER = "0.0.0"
6 COMPANY_NAME = "MVBA, P.C."
7 COPYRIGHT = "MVBA, P.C. (c) 2019-2013"
8 ARTIFACTS = File.expand_path("dist")
9 COMPILE_TARGET = "Debug"
10 STAGE = File.expand_path("build")
11 SETTINGS_DIR = "settings"
56c8cf4 @handcraftsman autoconvert newlines
handcraftsman authored
12
870995d @wbinford Standardized build and updated README.md
wbinford authored
13 nunit_cmd = "tools/NUnit/bin/nunit-console.exe"
56c8cf4 @handcraftsman autoconvert newlines
handcraftsman authored
14
870995d @wbinford Standardized build and updated README.md
wbinford authored
15 beginning = Time.now
56c8cf4 @handcraftsman autoconvert newlines
handcraftsman authored
16
870995d @wbinford Standardized build and updated README.md
wbinford authored
17 default_settings = { :artifacts => ARTIFACTS,
18 :compile_target => COMPILE_TARGET,
19 :stage => STAGE
20 }
56c8cf4 @handcraftsman autoconvert newlines
handcraftsman authored
21
870995d @wbinford Standardized build and updated README.md
wbinford authored
22 def read_config(settings_directory, env)
23 settings = {}
24 default_settings_file = "#{settings_directory}/#{env}.default.yaml"
25 if File.exists?(default_settings_file) then
26 settings = YAML.load_file(default_settings_file)
27 end
28 settings_file = "#{settings_directory}/#{env}.yaml"
29 if File.exists?(settings_file) then
30 overrides = YAML.load_file(settings_file)
31 overrides.each do |k,v|
32 settings[k] = v
33 end
34 end
35 return settings
56c8cf4 @handcraftsman autoconvert newlines
handcraftsman authored
36 end
37
870995d @wbinford Standardized build and updated README.md
wbinford authored
38 environment = ENV['environment']
39 settings = read_config(SETTINGS_DIR, environment)
40 default_settings.each { |key, val| if settings[key].nil? then settings[key] = default_settings[key] end }
41
42 puts "Rakefile settings:"
43 settings.each { |key, val| puts "#{key} => #{val}" }
44 puts
45
46
47 desc "** Default **"
48 task :default => [:build, :copy_artifacts, :test, :archive] do
49 puts "Build Succeeded - time elapsed: #{Time.now - beginning} seconds"
50 end
51
52 desc "Creates CommonAssemblyInfo.cs file"
53 assemblyinfo :assemblyinfo do |asm|
54 build_number = get_build_number
55 build_number_with_hash = get_build_number_with_hash
56 asm.product_name = PRODUCT_NAME
57 asm.version = build_number
58 asm.file_version = build_number
59 asm.trademark = build_number_with_hash
60 asm.company_name = COMPANY_NAME
61 asm.copyright = COPYRIGHT
62 asm.output_file = "src/CommonAssemblyInfo.cs"
63 end
64
f2756c8 @handcraftsman update libraries to 4.5; change framework to 4.5; fix resharper 8 issues
handcraftsman authored
65 desc "Add Resharper escapes to CommonAssemblyInfo.cs file"
66 task :resharperAssemblyInfo do
67 puts
68 puts "adding Resharper escapes to src/CommonAssemblyInfo.cs"
69 puts
70
71 File.open('src/CommonAssemblyInfo.cs', 'r+') do |f|
72 contents = f.read
73 f.rewind
74
75 f.puts "// ReSharper disable RedundantUsingDirective"
76 f.puts contents
77 f.puts "// ReSharper enable RedundantUsingDirective"
78 end
79 end
80
870995d @wbinford Standardized build and updated README.md
wbinford authored
81 desc "Builds the #{PRODUCT_NAME} solution"
f2756c8 @handcraftsman update libraries to 4.5; change framework to 4.5; fix resharper 8 issues
handcraftsman authored
82 msbuild :build => [:clean, :assemblyinfo, :resharperAssemblyInfo] do |msb|
870995d @wbinford Standardized build and updated README.md
wbinford authored
83 puts "Compiling #{PRODUCT_NAME} in #{settings[:compile_target]} mode..."
84 msb.properties :configuration => settings[:compile_target]
85 msb.targets :Clean, :Build
86 msb.solution = "src/#{PRODUCT_NAME}.sln"
87 msb.verbosity = "quiet"
88 sleep 1
56c8cf4 @handcraftsman autoconvert newlines
handcraftsman authored
89 end
90
870995d @wbinford Standardized build and updated README.md
wbinford authored
91 desc "Copy build artifacts to the staging folder"
92 task :copy_artifacts => [:build] do
93 puts "Copying files from bin folders to the build folder (#{settings[:stage]})..."
1e3d7a5 @wbinford Updated dependent dlls
wbinford authored
94 copy_output_files "src/#{PRODUCT_NAME}/bin/#{settings[:compile_target]}", "*.{dll,pdb,exe}", settings[:stage]
870995d @wbinford Standardized build and updated README.md
wbinford authored
95 copy_output_files "src/#{PRODUCT_NAME}.Tests/bin/#{settings[:compile_target]}", "*.{dll,pdb,exe}", settings[:stage]
32294ed @wbinford Added License.txt and Provenance.txt to artifacts
wbinford authored
96 FileUtils.cp_r "License.txt", "#{settings[:stage]}/#{PRODUCT_NAME}.License.txt"
97 FileUtils.cp_r "Provenance.txt", "#{settings[:stage]}/#{PRODUCT_NAME}.Provenance.txt"
56c8cf4 @handcraftsman autoconvert newlines
handcraftsman authored
98 end
99
100 desc "Prepares the working directory for a new build"
101 task :clean do
870995d @wbinford Standardized build and updated README.md
wbinford authored
102 FileUtils.rm_rf settings[:stage]
103 # work around nasty latency issue where folder still exists for a short while after it is removed
104 wait_for { !Dir.exists?(settings[:stage]) }
105 Dir.mkdir settings[:stage]
106 Dir.mkdir settings[:artifacts] unless Dir.exists?(settings[:artifacts])
56c8cf4 @handcraftsman autoconvert newlines
handcraftsman authored
107 end
108
870995d @wbinford Standardized build and updated README.md
wbinford authored
109 desc "Runs the unit tests"
110 nunit :test do |nunit|
111 puts "Running the unit tests in the build folder (#{settings[:stage]})..."
112 nunit.command = nunit_cmd
113 nunit.options "/framework #{CLR_TOOLS_VERSION}"
114 nunit.assemblies "#{settings[:stage]}/#{PRODUCT_NAME}.Tests.dll"
115 end
116
117 desc "Zips up the build results"
118 zip :archive do |zip|
119 puts "Zipping up the build folder and copying to artifact folder (#{settings[:artifacts]})..."
120 mkdir settings[:artifacts] unless Dir.exists?(settings[:artifacts])
121 build_number = get_build_number
122 zip.directories_to_zip = [settings[:stage]]
123 zip.output_file = "#{PRODUCT_NAME}_#{build_number}.#{settings[:compile_target]}.zip"
124 zip.output_path = [settings[:artifacts]]
125 puts "Artifacts are available in the artifact folder: #{settings[:artifacts]}"
56c8cf4 @handcraftsman autoconvert newlines
handcraftsman authored
126 end
127
870995d @wbinford Standardized build and updated README.md
wbinford authored
128 def copy_output_files(fromDir, filePattern, outDir)
129 Dir.glob(File.join(fromDir, filePattern)){|file|
130 copy(file, outDir) if File.file?(file)
131 }
132 end
133
134 def get_build_number
135 begin
136 gittag = `git describe --long`.chomp # looks something like v0.1.0-63-g3f10c2e
137 puts "gittag: #{gittag}"
138 parts = gittag.split("-")
139 base_version = parts[0].gsub("v","")
140 git_build_revision = parts[1]
141 git_short_hash = parts[2]
142 puts "base_version: #{base_version}"
143 puts "git_build_revision: #{git_build_revision}"
144 puts "git_short_hash: #{git_short_hash}"
145 build_number = "#{base_version}.#{git_build_revision}"
146 rescue
147 build_number = DEFAULT_BUILD_NUMBER
148 end
56c8cf4 @handcraftsman autoconvert newlines
handcraftsman authored
149 end
150
870995d @wbinford Standardized build and updated README.md
wbinford authored
151 def get_build_number_with_hash
152 begin
153 gittag = `git describe --long`.chomp # looks something like v0.1.0-63-g3f10c2e
154 #puts "gittag: #{gittag}"
155 parts = gittag.split("-")
156 base_version = parts[0].gsub("v","")
157 git_build_revision = parts[1]
158 git_short_hash = parts[2]
159 build_number_with_hash = "#{base_version}.#{git_build_revision}-#{git_short_hash}"
160 rescue
161 build_number_with_hash = DEFAULT_BUILD_NUMBER
162 end
163 end
164
165 def wait_for(&block)
166 checks = 0
167 until block.call || checks >10
168 sleep 0.5
169 checks += 1
170 end
171 raise 'waitfor timeout expired' if checks > 10
172 end
Something went wrong with that request. Please try again.