4
4
Uses the WiX Toolset v4 to create the installer.
5
5
6
6
Requirements:
7
- - .NET SDK 6.0 or later
8
7
- WiX Toolset v4 installed as a .NET tool (dotnet tool install --global wix)
9
8
10
9
Features:
11
- - Creates a deterministic Product ID based on version number
10
+ - Includes all files and subdirectories from the input directory
12
11
- Allows same-version upgrades to replace existing installations
13
12
- Properly handles upgrades to prevent duplicate entries in Add/Remove Programs
13
+ - Creates start menu shortcuts
14
14
15
15
Usage:
16
16
python scripts/create_windows_msi.py --input-dir dist/GetDistGUI --output-dir dist --version 1.6.3
@@ -43,18 +43,6 @@ def find_version():
43
43
def check_wix_installed ():
44
44
"""Check if WiX Toolset v4 is installed"""
45
45
try :
46
- # First check if .NET SDK is installed
47
- dotnet_result = subprocess .run (["dotnet" , "--version" ],
48
- stdout = subprocess .PIPE ,
49
- stderr = subprocess .PIPE ,
50
- text = True ,
51
- check = False )
52
-
53
- if dotnet_result .returncode != 0 :
54
- print (f".NET SDK check failed: { dotnet_result .stderr .strip ()} " )
55
- print ("ERROR: .NET SDK 6.0 or later is required for WiX v4" )
56
- return False
57
-
58
46
# Try to run wix.exe to check if WiX v4 is installed
59
47
result = subprocess .run (["wix" , "--version" ],
60
48
stdout = subprocess .PIPE ,
@@ -78,8 +66,7 @@ def install_wix():
78
66
"""Provide instructions for installing WiX Toolset v4"""
79
67
print ("WiX Toolset v4 not found." )
80
68
print ("\n Please install WiX Toolset v4 manually:" )
81
- print ("1. Install the .NET SDK 6.0 or later" )
82
- print ("2. Run: dotnet tool install --global wix --version 6.0.0" )
69
+ print ("Run: dotnet tool install --global wix --version 6.0.0" )
83
70
print ("" )
84
71
return False
85
72
@@ -177,19 +164,36 @@ def create_wix_files(input_dir, version):
177
164
# Use forward slashes for paths to avoid escaping issues
178
165
input_dir_forward = input_dir .replace ('\\ ' , '/' )
179
166
180
- # Get a list of all files in the directory except GetDistGUI.exe
167
+ # Get a list of all files in the directory and subdirectories
181
168
files = []
182
- for file in os .listdir (input_dir ):
183
- if file != "GetDistGUI.exe" and os .path .isfile (os .path .join (input_dir , file )):
184
- files .append (file )
169
+ file_id_counter = 1
170
+
171
+ # Walk through all directories and files
172
+ for root , _ , filenames in os .walk (input_dir ): # Use _ to indicate unused variable
173
+ rel_dir = os .path .relpath (root , input_dir ).replace ('\\ ' , '/' )
174
+ if rel_dir == '.' :
175
+ rel_dir = ''
176
+ else :
177
+ rel_dir += '/'
178
+
179
+ for filename in filenames :
180
+ if os .path .join (root , filename ) == os .path .join (input_dir , "GetDistGUI.exe" ):
181
+ continue # Skip the main executable, it's handled separately
182
+
183
+ rel_path = rel_dir + filename
184
+ files .append ((rel_path , file_id_counter ))
185
+ file_id_counter += 1
185
186
186
187
# Create component entries for each file
187
188
file_components = ""
188
- for i , file in enumerate (files ):
189
- file_id = f"File{ i + 1 } "
189
+ for rel_path , id_num in files :
190
+ file_id = f"File{ id_num } "
191
+ component_id = f"Component{ id_num } "
192
+
193
+ # Add component for this file
190
194
file_components += f"""
191
- <Component Id="Component { i + 1 } " Guid="*">
192
- <File Id="{ file_id } " Source="{ input_dir_forward } /{ file } " KeyPath="yes" />
195
+ <Component Id="{ component_id } " Guid="*">
196
+ <File Id="{ file_id } " Source="{ input_dir_forward } /{ rel_path } " KeyPath="yes" />
193
197
</Component>"""
194
198
195
199
components_content = f"""<?xml version="1.0" encoding="UTF-8"?>
0 commit comments