diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bd63af0e..3b36deb5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -702,7 +702,7 @@ jobs:
export MSI_FILENAME="${GITHUB_WORKSPACE}/gam-${GAMVERSION}-windows-${GAM_ARCHIVE_ARCH}.msi"
# auto-generate a lib.wxs based on the files PyInstaller created for the lib/ directory
/c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.14/bin/heat.exe dir "${gampath}/lib" -ke -srd -cg Lib -gg -dr lib -directoryid lib -out lib-fixme.wxs
- sed 's/Guid=\".*\"/Guid="*"/g' lib-fixme.wxs > lib.wxs
+ $python tools/gen-wix-xml-filelist.py lib.wxs
echo "-- begin lib.wxs --"
cat lib.wxs
echo "-- end lib.wxs --"
diff --git a/src/tools/gen-wix-xml-filelist.py b/src/tools/gen-wix-xml-filelist.py
index 8702ee63..e7c9474f 100644
--- a/src/tools/gen-wix-xml-filelist.py
+++ b/src/tools/gen-wix-xml-filelist.py
@@ -1,58 +1,23 @@
-import os
-import sys
import uuid
+from lxml import etree
+import sys
-source_dir = sys.argv[1]
-template_file = sys.argv[2]
-target_file = sys.argv[3]
+# Hacky solution to create a Guid for all files
+# so Wix is happy and Guid is stable every time.
+# uuid5 is used for the Guid and the input is the
+# source filename so the Guid will be the same
+# every time as long as the source file name is
+# the same.
-existing_components = {
- 'gam.exe': '''
-
-
-
-''',
- 'LICENSE': '''
-
-
-''',
- 'gam-setup.bat': '''
-
-
-''',
- 'GamCommands.txt': '''
-
-
-''',
- 'GamUpdate.txt': '''
-
-
-''',
- 'cacerts.pem': '''
-
-
-''',
-}
-
-component_xml = ''
-all_files = []
-for root, dirs, files in os.walk(source_dir):
- for filename in files:
- relpath = os.path.relpath(root, source_dir)
- if relpath == '.':
- all_files.append(filename)
- else:
- all_files.append(os.path.join(relpath, filename))
-all_files.sort()
-for filename in all_files:
- component_xml += existing_components.get(filename,
- f' \n \n \n')
-
-with open(template_file, 'r') as f:
- template = f.read()
-
-full_xml = template.replace('REPLACE_ME_WITH_FILE_COMPONENTS', component_xml)
-
-with open(target_file, 'w') as f:
- f.write(full_xml)
+rewrite_file = sys.argv[1]
+with open(rewrite_file, 'rb') as f:
+ input_xml = f.read()
+root = etree.fromstring(input_xml)
+for elem in root.getiterator():
+ if 'Guid' in elem.attrib:
+ source = elem.getchildren()[0].attrib['Source']
+ stable_uuid = str(uuid.uuid5(uuid.NAMESPACE_URL, source))
+ elem.attrib['Guid'] = stable_uuid
+with open(rewrite_file, 'w') as f:
+ f.write(etree.tostring(root).decode())