forked from reactiveui/ReactiveUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
201 lines (154 loc) · 6.24 KB
/
Rakefile
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
require 'albacore'
require 'fileutils'
#
# COOLSTUFF: Rake tasks to automate common tasks
#
# If you install Ruby (via http://ruby-lang.org), as well as the Albacore gem
# (gem install albacore), Kitchen Sink comes with an automated build and
# packaging system, which is really easy to extend.
#
# Some Interesting Commands:
#
# rake build # Builds all of your solutions, and places files in ./bin
#
# rake publish # Publishes your app using ClickOnce, and zips up a copy of the
# # binaries in the same folder
#
###
### Project Settings
###
HolyCrapDidIActuallyReadThisSection = true
ProductInformation = {
:product_name => "Reactive XAML",
:version => "1.1.1.0",
:company_name => "Paul Betts",
:description => "An MVVM framework that integrates the Reactive Extensions",
}
CustomPrebuildTasks = {
:reactivexaml => [:assemblyinfo_reactivexaml, :assemblyinfo_reactivexamlblend],
}
###
### Custom Tasks
###
desc "Generate an AssemblyInfo.cs for ReactiveUI"
assemblyinfo :assemblyinfo_reactivexaml do |asm|
ProductInformation.each {|k,v| set_property(asm, k, v)}
asm.output_file = "ReactiveUI/Properties/AssemblyInfo.cs"
end
desc "Generate an AssemblyInfo.cs for ReactiveUI.Blend"
assemblyinfo :assemblyinfo_reactivexamlblend do |asm|
ProductInformation.each {|k,v| set_property(asm, k, v)}
asm.product_name = "Reactive XAML Expression Blend"
asm.output_file = "ReactiveUI.Blend/Properties/AssemblyInfo.cs"
end
###############################################################################
##
## STOP READING NOW, you don't *have* to edit this section, unless you want to
## of course.
##
###############################################################################
###
### Constants and functions that don't need to be changed per project
###
RootProjectDir = File.dirname(__FILE__)
def sln_file_to_name(path, prefix)
an_underscore = prefix ? '_' : ''
fancy_name = [prefix, an_underscore, File.basename(path, '.sln').gsub(/([-_]|\.)/, '')].join('').downcase
fancy_name.to_sym
end
def set_property(object, property, value)
object.send((property.to_s + '=').to_sym, value)
end
def publish_dir_for_sln(sln_file)
"#{ClickOnceRootPublishLocation}/#{sln_file_to_name(sln_file, nil)}"
end
@all_solution_files = Dir.glob(File.join(RootProjectDir, '**', '*.sln'))
###
### Generated Tasks
###
@all_solution_files.each do |sln_file|
clean_task_names = ["clean_dbg", "clean_rel"].map{|x| sln_file_to_name(sln_file,x)}
desc "Cleans '#{sln_file}'"
task sln_file_to_name(sln_file, "clean") => clean_task_names
clean_task_names.zip([:debug, :release]).each do |x|
msbuild x[0] do |msb|
msb.solution = sln_file
msb.properties = {:configuration => x[1]}
msb.targets [:clean]
end
end
custom_prebuild_tasks = CustomPrebuildTasks[sln_file_to_name(sln_file, nil)] || []
desc "Builds '#{sln_file}'"
msbuild sln_file_to_name(sln_file, "build") => custom_prebuild_tasks do |msb|
msb.solution = sln_file
msb.properties = {
:configuration => :release,
:applicationversion => ProductInformation[:version],
}
msb.targets [:build]
end
clean_and_build = ["clean", "build"].map {|x| sln_file_to_name(sln_file, x)}
desc "Publishes '#{sln_file}'"
msbuild sln_file_to_name(sln_file, "publish") => clean_and_build do |msb|
# NB: These paths have to end in a slash or else MSBuild loses it
publish_dir = publish_dir_for_sln(sln_file) + '/'
msb.solution = sln_file
msb.properties = {
:configuration => :release,
:publishdir => publish_dir,
:publishurl => publish_dir,
:installurl => publish_dir,
:applicationversion => ProductInformation[:version]
}
msb.targets [:publish]
end
end
@bin_dir = File.join(RootProjectDir, 'bin')
desc "Clears out the 'bin' directory"
task :blow_away_bin_folder do
FileUtils.rm_rf @bin_dir
end
desc "Clears out the TestResults directory"
task :blow_away_test_results do
FileUtils.rm_rf File.join(RootProjectDir, 'TestResults')
end
desc "Copies binaries from all of the subprojects to one 'bin' folder"
task :copy_binaries_to_bin_folder do
Dir.glob("**/bin/Release").each do |release_dir|
`robocopy "#{release_dir}" "#{@bin_dir}" /MIR`
end
end
desc "Publishes a zipped archive of the binaries for a particular release"
zip :publish_archive do |z|
z.directories_to_zip 'bin'
z.output_file = "Binaries-#{ProductInformation[:version]}-#{Time.now.strftime('%Y%m%d-%H%M%S')}.zip"
z.output_path = File.join(RootProjectDir, '..')
end
desc "Publishes a zipped archive of the source files"
zip :source_zip => :clean do |z|
z.directories_to_zip RootProjectDir
z.output_file = "#{File.basename(RootProjectDir)}-#{ProductInformation[:version]}-#{Time.now.strftime('%Y%m%d-%H%M%S')}.zip"
z.output_path = File.join(RootProjectDir, '..')
end
###
### Generate the "all" tasks
###
desc "Cleans all projects"
task :clean => @all_solution_files.map{|f| sln_file_to_name(f, "clean")} + [:blow_away_bin_folder, :blow_away_test_results]
desc "Builds all projects"
task :build => @all_solution_files.map{|f| sln_file_to_name(f, "build")} + [:copy_binaries_to_bin_folder]
desc "Publishes all projects"
task :publish => @all_solution_files.map{|f| sln_file_to_name(f, "publish")} + [:copy_binaries_to_bin_folder, :publish_archive]
task :default => [:build]
# Punish those who don't read the README
unless HolyCrapDidIActuallyReadThisSection
STDERR.puts <<-EOS
*************************************************************************
** **
** Hey! You need to edit Rakefile before you can actually use this, or **
** else weird things will happen. **
** **
*************************************************************************
EOS
exit 1
end