forked from gitextensions/gitextensions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rakefile.rb
120 lines (98 loc) · 3.04 KB
/
rakefile.rb
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
# To rebuild everything and create the msi installers run:
#
# rake rebuild_setup
#
# To rebuild everything and install Git Extensions run:
#
# rake install
#
# To change the version number of the installer, create a
# git tag with the required number. If the current HEAD does
# not have a tag then git will create a description based on
# the last tag it is able to find in the history.
#
# Git may, for example, describe a version such as 1.91-79-g05ccafd.
# This means that the current HEAD is 79 commits past the 1.91
# release and its hash starts with 05ccafd.
#
VERSION = `git describe --tags`.strip
MSBUILD = "#{ENV['WinDir']}/Microsoft.NET/Framework/v3.5/msbuild.exe"
CSPROJECTS = "**/*.csproj"
MSIPROJECT = "Setup/Setup.wixproj"
SHELL_EXT = "SimpleExt/SimpleExt.sln"
CONFIG = "Release"
ENV["SkipShellExtRegistration"] = "yes"
# don't write the command to be executed by 'sh' to stdout
verbose(false)
def tasks
task :default => :compile
task :rebuild => [:clean, :compile]
task :compile => msbuild_all('build')
task :clean => msbuild_all('clean')
task :rebuild_setup => [:clean_setup, :setup]
task :setup => [:normal_setup, :complete_setup]
task :complete_setup => wix_complete('build')
task :normal_setup => wix('build')
task :clean_setup do
FileUtils.rm_rf 'Setup/bin'
FileUtils.rm_rf 'Setup/obj'
end
task :install => [:rebuild, :clean_setup, :normal_setup] do
install_msi
end
end
def install_msi(suffix=nil)
msi = "Setup\\bin\\#{CONFIG}\\#{msi_name}#{suffix}.msi"
sh "msiexec.exe /i #{msi}"
end
def msbuild_all(target)
msbuild_csprojects(target) <<
msbuild(target, SHELL_EXT, {"Platform" => "Win32"}) <<
msbuild(target, SHELL_EXT, {"Platform" => "x64"})
end
def msbuild_csprojects(target)
FileList[CSPROJECTS].map {|x| msbuild(target, x)}
end
def wix_complete(target)
wix(target, 'Complete', true)
end
def wix(target, suffix=nil, extra_software=false)
msbuild(target, MSIPROJECT, {
"OutputName" => msi_name(suffix),
"Version" => VERSION,
"NumericVersion" => msi_numeric_version,
"IncludeRequiredSoftware" => if extra_software then 1 else 0 end,
}, suffix)
end
def msi_name(suffix='')
"GitExtensions#{VERSION.gsub(/-g.*/, '').gsub(/\./,'')}Setup#{suffix}"
end
def msi_numeric_version(suffix='')
VERSION.gsub(/-/,'.').gsub(/\.g.*/,'')
end
def msbuild(target, project, props={}, suffix=nil)
platform = ":#{props['Platform']}" if props.key?('Platform')
suffix = ":#{suffix}" if suffix != nil
task "#{target}#{platform}#{suffix}:#{project}" do
run_msbuild(target, project, props)
end
end
def run_msbuild(target, project, props)
cmd = "#{MSBUILD} "
cmd += "/nologo /m /v:m "
props.each{|k,v| cmd += "/p:#{k}=\"#{v}\" "}
cmd += "/p:Configuration=#{CONFIG} "
cmd += "/t:#{target} #{project}"
prop_desc = props.to_a.map{|x| "#{x[0]} = #{x[1]}"}.join(', ')
desc = project
desc += " (#{prop_desc})" if prop_desc.size != 0
if target == 'clean' then
puts "Cleaning #{desc}"
else
puts "Building #{desc}"
end
startTime = Time.now
sh cmd
endTime = Time.now
end
tasks