/
package.rb
64 lines (47 loc) · 1.73 KB
/
package.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
require 'uuid'
require 'rake/packagetask'
task :package => [:build, 'installer:package']
Rake::PackageTask.new('pik-update', Pik::VERSION) do |p|
p.need_zip = true
p.package_files.include("tools/pik_runner.exe",'tools/pik.bat','tools/pik.ps1')
end
### installer
require 'nokogiri'
namespace :installer do
def version_string
@version.gsub(".","")
end
directory 'pkg'
@package = 'pik'
@wix_file = "lib/installer/#{@package}.wxs"
@wxs = Nokogiri::XML(File.open(@wix_file))
@product = @wxs.at_css("Product")
msi_file = "pkg/#{@package}-#{Pik::VERSION}.msi"
file msi_file, :needs => 'tools/pik_runner.exe'
desc "packages the msi installer"
task :package, :needs => [msi_file, :light]
task :candle do
chdir 'lib/installer/' do
cmd = "../../tmp/wix/candle.exe -nologo"
wxs_files = ["MyInstallDirDialog.wxs",'WixUI_MyInstallDir.wxs' , "#{@package}.wxs"].join(' ')
sh("#{cmd} #{wxs_files}")
end
end
task :light, :needs => :candle do
chdir 'lib/installer/' do
cmd = "../../tmp/wix/light.exe -nologo "
wixobj_files = ["MyInstallDirDialog.wixobj", 'WixUI_MyInstallDir.wixobj', "#{@package}.wixobj"].join(' ')
sh("#{cmd} -ext WixUtilExtension -ext WixUIExtension #{wixobj_files} -o ../../#{msi_file}")
end
end
desc "updates wix xml file to prep for a new version"
task :upgrade do
@product["Version"] = Pik::VERSION
upgrade_max = @product.at_css("UpgradeVersion[Property = 'OLDAPPFOUND']")
upgrade_max["Maximum"] = Pik::VERSION
upgrade_min = @product.at_css("UpgradeVersion[Property = 'NEWAPPFOUND']")
upgrade_min["Minimum"] = Pik::VERSION
@product["Id"] = UUID.new.generate
File.open(@wix_file, 'w+'){|f| f.puts @wxs }
end
end