@@ -106,25 +106,47 @@ function _get_cp_kind_table(package, cmds, opt)
106
106
return result
107
107
end
108
108
109
+ -- get id
110
+ function _get_id (name )
111
+ return " A" .. hash .uuid (name ):gsub (" -" , " ." )
112
+ end
113
+
114
+ -- for each id/guid in the file wix want them to be unique
115
+ -- so compute a hash for each directory based on the file that are inside
116
+ function _get_dir_id (cp_table )
117
+ local hashes = {}
118
+ for dir , files in pairs (cp_table ) do
119
+ local s = " "
120
+ for _ , file in ipairs (files ) do
121
+ s = s .. table.concat (file , " " )
122
+ end
123
+ -- wix required id to start with a letter and without any hyphen
124
+ hashes [dir ] = _get_id (s )
125
+ end
126
+ return hashes
127
+ end
128
+
129
+ -- get custom commands
109
130
function _get_other_commands (package , cmd , opt )
110
131
opt = table .join (cmd .opt or {}, opt )
111
132
local result = " "
112
133
local kind = cmd .kind
134
+ local id = _get_id ()
113
135
if kind == " rm" then
114
136
local subdirectory = _translate_filepath (package , path .directory (cmd .filepath ))
115
137
subdirectory = subdirectory ~= " ." and string.format ([[ Subdirectory="%s"]] , subdirectory ) or " "
116
138
local on = opt .install and [[ On="install"]] or [[ On="uninstall"]]
117
139
local filename = path .filename (cmd .filepath )
118
- result = string.format ([[ <RemoveFile Directory="INSTALLFOLDER" Name="%s" %s %s/>]] , filename , subdirectory , on )
140
+ result = string.format ([[ <RemoveFile Id="%s" Directory="INSTALLFOLDER" Name="%s" %s %s/>]] , id , filename , subdirectory , on )
119
141
elseif kind == " rmdir" then
120
142
local dir = _translate_filepath (package , cmd .dir )
121
143
local subdirectory = dir ~= " ." and string.format ([[ Subdirectory="%s"]] , dir ) or " "
122
144
local on = opt .install and [[ On="install"]] or [[ On="uninstall"]]
123
- result = string.format ([[ <RemoveFolder Directory="INSTALLFOLDER" %s %s/>]] , subdirectory , on )
145
+ result = string.format ([[ <RemoveFolder Id="%s" Directory="INSTALLFOLDER" %s %s/>]] , id , subdirectory , on )
124
146
elseif kind == " mkdir" then
125
147
local dir = _translate_filepath (package , cmd .dir )
126
148
local subdirectory = dir ~= " ." and string.format ([[ Subdirectory="%s"]] , dir ) or " "
127
- result = string.format ([[ <CreateFolder Directory="INSTALLFOLDER" %s/>]] , subdirectory )
149
+ result = string.format ([[ <CreateFolder Id="%s" Directory="INSTALLFOLDER" %s/>]] , id , subdirectory )
128
150
elseif kind == " wix" then
129
151
result = cmd .rawstr
130
152
end
@@ -149,21 +171,6 @@ function _get_component_string(id, subdirectory)
149
171
return string.format ([[ <Component Id="%s" Guid="%s" Directory="INSTALLFOLDER" %s>]] , id :gsub (" [ ()]" , " " ), hash .uuid (id ), subdirectory )
150
172
end
151
173
152
- -- for each id/guid in the file wix want them to be unique
153
- -- so compute a hash for each directory based on the file that are inside
154
- function _get_dir_id (cp_table )
155
- local hashes = {}
156
- for dir , files in pairs (cp_table ) do
157
- local s = " "
158
- for _ , file in ipairs (files ) do
159
- s = s .. table.concat (file , " " )
160
- end
161
- -- wix required id to start with a letter and without any hyphen
162
- hashes [dir ] = " A" .. hash .uuid (s ):gsub (" -" , " ." )
163
- end
164
- return hashes
165
- end
166
-
167
174
-- build a feature from batchcmds
168
175
function _build_feature (package , opt )
169
176
opt = opt or {}
@@ -185,7 +192,7 @@ function _build_feature(package, opt)
185
192
for _ , file in ipairs (files ) do
186
193
local srcfile = file [1 ]
187
194
local dstname = file [2 ]
188
- table.insert (result , string.format ([[ <File Source="%s" Name="%s"/>]] , srcfile , dstname ))
195
+ table.insert (result , string.format ([[ <File Source="%s" Name="%s" Id="%s" />]] , srcfile , dstname , _get_id ( srcfile .. dstname ) ))
189
196
end
190
197
table.insert (result , " </Component>" )
191
198
end
0 commit comments