# Loops through a WiX project (change the wixfilename variable to specify the filename) to
# * slice the Name attribute if it's too long (non-8.3 compliant)
# * append _x (where x is a number) before the dot in the Name attribute
# * set the LongName parameter to the old value of Name if it fixes the Name parameter as above
# * set the
require 'rexml/document'
include REXML
wixfilename = "test.wxs"
xf = File.open(wixfilename, 'r')
xd = Document.new xf.read
xf.close
#slice everything to 8.3 lengths. For example, myapplication.config will get sliced to myapplic.config
XPath.each xd, "//Wix:File", {'Wix', 'http://schemas.microsoft.com/wix/2003/01/wi' } do |f|
file_name = f.attributes['Name'].split('.')[0]
file_ext = f.attributes['Name'].split('.')[1]
if file_name.length > 8 or file_ext.length > 3
short_file_name = f.attributes['Name'].split('.')[0].slice(0..7)
short_file_ext = f.attributes['Name'].split('.')[1].slice(0..2)
f.attributes['LongName'] = f.attributes['Name']
count = 0
f.attributes['Name'] = short_file_name + '.' + short_file_ext
end
if f.attributes['LongName'] != nil
f.attributes['Id'] = f.attributes['LongName']
else
f.attributes['Id'] = f.attributes['Name']
end
end
#look for duplicates. If it finds any, it will further slice it to 6.3 and append _x, where x is a number.
XPath.each xd, "//Wix:File", {'Wix', 'http://schemas.microsoft.com/wix/2003/01/wi'
} do |f|
name = f.attributes['Name']
matches = XPath.match xd, "//Wix:[EMAIL PROTECTED] = '#{name}']", {'Wix', '
http://schemas.microsoft.com/wix/2003/01/wi'}
if matches.length > 1
count = 0
matches.each do |m|
short_file_name = f.attributes['Name'].split('.')[0].slice(0..5)
short_file_ext = f.attributes
['Name'].split('.')[1].slice(0..2)
count = count + 1
m.attributes['Name'] = "#{short_file_name}_#{count}.#{short_file_ext}"
end
end
end
xf = File.open(wixfilename, 'w')
xd.write xf
xf.close
From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Rob Mensching
Sent: Monday, June 05, 2006 9:40 PM
To: Simon Burgess; wix-users@lists.sourceforge.net
Subject: Re: [WiX-users] Unique Short Names?
Possibly. If your install ever ends up on a short name system (and you don't have complete control over that) then you're going to be seriously hosed.
From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
] On Behalf Of Simon Burgess
Sent: Monday, June 05, 2006 1:49 PM
To:
wix-users@lists.sourceforge.net
Subject: [WiX-users] Unique Short Names?
I am using the latest wix v2.
Does anyone know if the 'Name' attribute on the <File> element needs to be unique? All of the file's I install I use the appropriate 'Longname' value, but as I 'm having trouble auto-generating short names I have used the same value for the 'Name' attribute for every file and it seems to work fine. Is this likely to cause me problems down the line?
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users
_______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users