Skip to content

Commit 65302af

Browse files
committed
wix4
1 parent a69b57a commit 65302af

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

scripts/create_windows_msi.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
Uses the WiX Toolset v4 to create the installer.
55
66
Requirements:
7-
- .NET SDK 6.0 or later
87
- WiX Toolset v4 installed as a .NET tool (dotnet tool install --global wix)
98
109
Features:
11-
- Creates a deterministic Product ID based on version number
10+
- Includes all files and subdirectories from the input directory
1211
- Allows same-version upgrades to replace existing installations
1312
- Properly handles upgrades to prevent duplicate entries in Add/Remove Programs
13+
- Creates start menu shortcuts
1414
1515
Usage:
1616
python scripts/create_windows_msi.py --input-dir dist/GetDistGUI --output-dir dist --version 1.6.3
@@ -43,18 +43,6 @@ def find_version():
4343
def check_wix_installed():
4444
"""Check if WiX Toolset v4 is installed"""
4545
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-
5846
# Try to run wix.exe to check if WiX v4 is installed
5947
result = subprocess.run(["wix", "--version"],
6048
stdout=subprocess.PIPE,
@@ -78,8 +66,7 @@ def install_wix():
7866
"""Provide instructions for installing WiX Toolset v4"""
7967
print("WiX Toolset v4 not found.")
8068
print("\nPlease 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")
8370
print("")
8471
return False
8572

@@ -177,19 +164,36 @@ def create_wix_files(input_dir, version):
177164
# Use forward slashes for paths to avoid escaping issues
178165
input_dir_forward = input_dir.replace('\\', '/')
179166

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
181168
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
185186

186187
# Create component entries for each file
187188
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
190194
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" />
193197
</Component>"""
194198

195199
components_content = f"""<?xml version="1.0" encoding="UTF-8"?>

0 commit comments

Comments
 (0)