Skip to content

Commit fb7a3db

Browse files
committed
feat: add WiX MSI packaging support for Windows installer
Add WiX Toolset integration for creating MSI installers for both dde-cooperation and data-transfer applications. This includes: - WiX build system integration with CMake - Platform-specific (x64/x86) installer generation - OpenSSL dependency packaging - Multi-language support (en/zh-CN) - GitHub Actions workflow for automated MSI builds - Batch script for local WiX builds Log: add WiX MSI packaging support for Windows installer.
1 parent 30621c5 commit fb7a3db

28 files changed

+2322
-112
lines changed

.github/workflows/windows-msvc.yml

Lines changed: 77 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Windows MSVC Release
2-
on:
2+
on:
33
push:
44
tags:
55
- "*"
@@ -9,47 +9,47 @@ jobs:
99
strategy:
1010
matrix:
1111
include:
12+
# 64-bit build
1213
- name: win64_msvc
1314
os: windows-2022
1415
build_type: Release
15-
compiler_type: msvc2019_64
1616
msvc_arch: x64
1717
qt_arch: win64_msvc2019_64
1818
qt_version: 5.15.2
1919
qt_target: desktop
20+
# 32-bit build
21+
- name: win32_msvc
22+
os: windows-2022
23+
build_type: Release
24+
msvc_arch: x86
25+
qt_arch: win32_msvc2019_64
26+
qt_version: 5.15.2
27+
qt_target: desktop
2028
runs-on: ${{ matrix.os }}
2129
env:
2230
BUILD_TYPE: ${{ matrix.build_type }}
23-
COMPILER_TYPE: ${{ matrix.compiler_type }}
2431
QT_VERSION: ${{ matrix.qt_version }}
25-
OPENSSL_ROOT_DIR: C:\Program Files\OpenSSL
26-
OPENSSL_INCLUDE_DIR: C:\Program Files\OpenSSL\include
27-
OPENSSL_CRYPTO_LIBRARY: C:\Program Files\OpenSSL\lib
32+
COO_PROJECT: dde-cooperation
33+
DT_PROJECT: data-transfer
34+
# OpenSSL paths based on architecture
35+
OPENSSL_ROOT_DIR: ${{ matrix.msvc_arch == 'x64' && 'C:\Program Files\OpenSSL' || 'C:\Program Files (x86)\OpenSSL' }}
2836
steps:
29-
# force 6.2.2 version of Inno Setup
30-
# - name: Install Inno Setup
31-
# run: |
32-
# choco install innosetup --version 6.2.2 --allow-downgrade -y
33-
34-
- name: '⚙️ Cache Qt'
37+
- name: "⚙️ Cache Qt"
3538
id: cache-qt
3639
uses: actions/cache@v3
3740
with:
3841
path: ..\Qt
39-
key: Windows-QtCache-${{ env.QT_VERSION }}
42+
key: Windows-QtCache-${{ env.QT_VERSION }}-${{ matrix.qt_arch }}
4043

41-
- name: Install Qt ${{ env.QT_VERSION }}
44+
- name: Install Qt ${{ env.QT_VERSION }} ${{ matrix.qt_arch }}
4245
uses: jurplel/install-qt-action@v3
4346
with:
44-
aqtversion: '==3.1.*'
47+
aqtversion: "==3.1.*"
4548
version: ${{ env.QT_VERSION }}
4649
target: ${{ matrix.qt_target }}
4750
arch: ${{ matrix.qt_arch }}
48-
# modules: 'qt5compat'
49-
# cached: 'false'
5051
cached: ${{ steps.cache-qt.outputs.cache-hit }}
5152

52-
# Use CMake 3.31.x for better OpenSSL 3.x compatibility while supporting VS 2022
5353
- name: Setup cmake
5454
uses: lukka/get-cmake@latest
5555
with:
@@ -63,115 +63,89 @@ jobs:
6363
fetch-depth: 0
6464

6565
- name: msvc-build
66-
id: build
6766
shell: cmd
6867
env:
6968
vc_arch: ${{ matrix.msvc_arch }}
7069
cmake_gen: Visual Studio 17 2022
71-
COO_PROJECT: dde-cooperation
72-
DT_PROJECT: data-transfer
73-
BONJOUR_SDK: ${{ github.workspace }}\source\3rdparty\ext\BonjourSDK
70+
APP_VERSION: ${{ github.ref_name }}
7471
run: |
75-
REM Use Visual Studio 2022 Enterprise (pre-installed on Windows 2022 runner)
72+
REM Use Visual Studio 2022 Enterprise
7673
set "VS2022_PATH=C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
77-
if not exist "%VS2022_PATH%\VC\Auxiliary\Build\vcvarsall.bat" (
78-
echo Visual Studio 2022 Enterprise not found at expected location!
79-
exit /b 1
80-
)
81-
echo Using Visual Studio 2022 at: %VS2022_PATH%
8274
call "%VS2022_PATH%\VC\Auxiliary\Build\vcvarsall.bat" %vc_arch%
83-
84-
REM Initialize OpenSSL environment (based on start.bat logic)
85-
echo ============== OpenSSL Initialization ==============
86-
echo Setting up OpenSSL environment...
87-
88-
REM Add OpenSSL bin directory to PATH (following start.bat pattern)
89-
set "PATH=%PATH%;%OPENSSL_ROOT_DIR%\bin"
90-
echo Updated PATH: %OPENSSL_ROOT_DIR%\bin added to PATH
91-
92-
REM Verify OpenSSL installation (like start.bat does)
93-
echo.
94-
echo Verifying OpenSSL installation:
95-
openssl version -a
96-
echo.
97-
echo OpenSSL environment ready
75+
76+
echo ============== Build Configuration ==============
77+
echo Architecture: %vc_arch%
78+
echo OpenSSL: %OPENSSL_ROOT_DIR%
79+
echo App Version: %APP_VERSION%
9880
echo ================================================
99-
100-
REM Display key OpenSSL environment variables
101-
echo OpenSSL Configuration:
102-
echo OPENSSL_ROOT_DIR: %OPENSSL_ROOT_DIR%
103-
echo OPENSSL_INCLUDE_DIR: %OPENSSL_INCLUDE_DIR%
104-
echo OPENSSL_CRYPTO_LIBRARY: %OPENSSL_CRYPTO_LIBRARY%
105-
echo.
106-
107-
mkdir build && cd build
108-
mkdir installer-inno
109-
echo Current working directory: %CD%
110-
echo Source directory: %GITHUB_WORKSPACE%\source
111-
if exist "%GITHUB_WORKSPACE%\source\CMakeLists.txt" (
112-
echo Found CMakeLists.txt in source directory
113-
cmake -G "%cmake_gen%" -A %vc_arch% -D CMAKE_BUILD_TYPE=%BUILD_TYPE% -D APP_VERSION="${{ github.ref_name }}" "%GITHUB_WORKSPACE%\source"
114-
) else (
115-
echo ERROR: CMakeLists.txt not found in source directory
116-
dir "%GITHUB_WORKSPACE%\source"
117-
exit /b 1
118-
)
119-
cmake --build . --config %BUILD_TYPE%
12081
121-
echo ------------copy files to output directory------------
82+
mkdir build && cd build
12283
123-
if exist output\%BUILD_TYPE% (
124-
copy output\%BUILD_TYPE%\* output\%COO_PROJECT%\%BUILD_TYPE%\ > NUL
125-
REM del output\%COO_PROJECT%\%BUILD_TYPE%\quazip* > NUL
126-
127-
copy "%OPENSSL_ROOT_DIR%\bin\libcrypto-3-x64.dll" output\%COO_PROJECT%\%BUILD_TYPE%\ > NUL
128-
copy "%OPENSSL_ROOT_DIR%\bin\libssl-3-x64.dll" output\%COO_PROJECT%\%BUILD_TYPE%\ > NUL
129-
130-
mkdir installer-inno\%COO_PROJECT%
131-
copy "%BONJOUR_SDK%\Bonjour64.msi" installer-inno\%COO_PROJECT%\ > NUL
132-
if exist output\%COO_PROJECT%\%BUILD_TYPE%\vc_redist.x64.exe (
133-
move output\%COO_PROJECT%\%BUILD_TYPE%\vc_redist.x64.exe installer-inno\%COO_PROJECT%\ > NUL
134-
)
84+
echo ------------CMake Configuration------------
85+
cmake -G "%cmake_gen%" -A %vc_arch% ^
86+
-D CMAKE_BUILD_TYPE=%BUILD_TYPE% ^
87+
-D CMAKE_PREFIX_PATH="%Qt5_DIR%" ^
88+
-D QT_VERSION=%QT_VERSION% ^
89+
-D APP_VERSION=%APP_VERSION% ^
90+
-D ENABLE_WIX=ON ^
91+
"%GITHUB_WORKSPACE%\source"
92+
if ERRORLEVEL 1 exit /b 1
13593
94+
echo ------------Build Project------------
95+
cmake --build . --config %BUILD_TYPE%
96+
if ERRORLEVEL 1 exit /b 1
13697
137-
REM copy output\%BUILD_TYPE%\quazip* output\%DT_PROJECT%\%BUILD_TYPE%\ > NUL
138-
139-
copy "%OPENSSL_ROOT_DIR%\bin\libcrypto-3-x64.dll" output\%DT_PROJECT%\%BUILD_TYPE%\ > NUL
140-
copy "%OPENSSL_ROOT_DIR%\bin\libssl-3-x64.dll" output\%DT_PROJECT%\%BUILD_TYPE%\ > NUL
141-
mkdir installer-inno\%DT_PROJECT%
142-
copy "%B_BONJOUR%\Bonjour64.msi" installer-inno\%DT_PROJECT%\ > NUL
143-
if exist output\%DT_PROJECT%\%BUILD_TYPE%\vc_redist.x64.exe (
144-
move output\%DT_PROJECT%\%BUILD_TYPE%\vc_redist.x64.exe installer-inno\%DT_PROJECT%\ > NUL
98+
echo ------------Copy Dependencies------------
99+
if exist output\%BUILD_TYPE% (
100+
if "%vc_arch%"=="x64" (
101+
copy "%OPENSSL_ROOT_DIR%\bin\libcrypto-3-x64.dll" output\%COO_PROJECT%\%BUILD_TYPE%\ > NUL
102+
copy "%OPENSSL_ROOT_DIR%\bin\libssl-3-x64.dll" output\%COO_PROJECT%\%BUILD_TYPE%\ > NUL
103+
copy "%OPENSSL_ROOT_DIR%\bin\libcrypto-3-x64.dll" output\%DT_PROJECT%\%BUILD_TYPE%\ > NUL
104+
copy "%OPENSSL_ROOT_DIR%\bin\libssl-3-x64.dll" output\%DT_PROJECT%\%BUILD_TYPE%\ > NUL
105+
) else (
106+
copy "%OPENSSL_ROOT_DIR%\bin\libcrypto-3-x86.dll" output\%COO_PROJECT%\%BUILD_TYPE%\ > NUL
107+
copy "%OPENSSL_ROOT_DIR%\bin\libssl-3-x86.dll" output\%COO_PROJECT%\%BUILD_TYPE%\ > NUL
108+
copy "%OPENSSL_ROOT_DIR%\bin\libcrypto-3-x86.dll" output\%DT_PROJECT%\%BUILD_TYPE%\ > NUL
109+
copy "%OPENSSL_ROOT_DIR%\bin\libssl-3-x86.dll" output\%DT_PROJECT%\%BUILD_TYPE%\ > NUL
145110
)
146-
) else (
147-
echo Remember to copy supporting binaries and configuration files!
148111
)
149112
150-
echo Build completed successfully
113+
echo ------------Build Packages (Inno + WiX)------------
114+
cmake --build . --config %BUILD_TYPE% --target package
115+
if ERRORLEVEL 1 echo Warning: Package build failed, continuing...
151116
152-
- name: Inno Setup data-transfer
153-
uses: nadeemjazmawe/[email protected]
154-
with:
155-
filepath: build/deepin-data-transfer-setup.iss
117+
- name: Make Installer Archives
118+
run: |
119+
# Archive all installers
120+
if exist "build/_CPack_Packages" (
121+
New-Item -ItemType Directory -Force -Path build/installers
122+
Get-ChildItem -Path build/_CPack_Packages -Recurse -Filter *.msi | ForEach-Object {
123+
$dest = "build/installers/$($_.Name)"
124+
Move-Item $_.FullName -Destination $dest -Force
125+
}
126+
Compress-Archive -Path build/installers/* -DestinationPath build/installers-${{ matrix.msvc_arch }}.zip
127+
}
128+
if exist "build/_CPack_Packages" (
129+
Get-ChildItem -Path build/_CPack_Packages -Recurse -Filter *.7z | ForEach-Object {
130+
Copy-Item $_.FullName -Destination build/
131+
}
132+
}
156133
157-
- name: Inno Setup cooperation
158-
uses: nadeemjazmawe/[email protected]
134+
- name: Upload Build Artifacts
135+
uses: actions/upload-artifact@v4
159136
with:
160-
filepath: build/dde-cooperation-setup.iss
161-
162-
- name: Make Installer Directories
163-
run: |
164-
move build/installer-inno/deepin-cooperation-* build/installer-inno/dde-cooperation/ > NUL
165-
powershell -Command "Compress-Archive -Path build/installer-inno/dde-cooperation/* -DestinationPath build/installer-inno/dde-cooperation.zip"
166-
move build/installer-inno/deepin-datatransfer-* build/installer-inno/data-transfer/ > NUL
167-
powershell -Command "Compress-Archive -Path build/installer-inno/data-transfer/* -DestinationPath build/installer-inno/deepin-data-transfer.zip"
137+
name: windows-installers-${{ matrix.msvc_arch }}
138+
path: |
139+
build/*.zip
140+
build/*.7z
141+
retention-days: 30
168142

169143
- name: Create Release
170144
uses: softprops/action-gh-release@v1
171145
if: startsWith(github.ref, 'refs/tags/')
172146
env:
173147
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
174148
with:
175-
files: build/installer-inno/*.zip
149+
files: build/*.zip
176150
generate_release_notes: true
177151
draft: true

.goosehints

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
1. Always respond in 中文,但注释和commit信息为英文;回复要求简洁,意思明确。
2+
2. C++项目触发mcp服务 promptx, 默认激活C++/Qt 开发(兼顾文档)专家角色 zero。
3+
3. 读取上次的任务状态获得对这个项目的记忆,避免每次会话都开启一个新的角色,导致做一些重复又不与上次吻合的事情。
4+
4. 在方案实施代码修改(实现)时,杜绝长篇大论,须遵守最小化修改原则!
5+
5. 完成一个任务或一个阶段后,保持状态到项目下 zero 的记忆。
6+
6. spec工作流的所有任务或阶段任务完成后,更新状态到 mcp promptx 服务。
7+
7. 代码的修改需要严肃仔细审查,不能因要解决问题而把原来大量的实现直接删除,杜绝这种不负责任的作法!
8+
8. 除非明确要求,否则不需生成独立报告文档!只需简略总结。
9+
9. 任何问题任务都必须严肃认真对待,所有结果均须根据事实,严禁胡编乱造!

CMakeLists.txt

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.13)
1+
cmake_minimum_required(VERSION 3.13)
22

33
project(dde-cooperation VERSION 0.1 LANGUAGES CXX)
44

@@ -72,25 +72,25 @@ if (WIN32)
7272

7373
# windows runtime output defined
7474
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${DEPLOY_OUTPUT_DIRECTORY})
75-
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${DEPLOY_OUTPUT_DIRECTORY})
76-
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${DEPLOY_OUTPUT_DIRECTORY})
75+
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${DEPLOY_OUTPUT_DIRECTORY})
76+
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${DEPLOY_OUTPUT_DIRECTORY})
7777

7878
file(GLOB INNO_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/dist/inno/scripts)
7979
file(COPY ${INNO_SCRIPTS} DESTINATION ${CMAKE_BINARY_DIR})
8080
endif()
8181

8282
# 如果未设置CMAKE_BUILD_TYPE,则将其设置为Release
8383
if(NOT CMAKE_BUILD_TYPE)
84-
message("Build type is not defined, default to Debug")
85-
set(CMAKE_BUILD_TYPE "Debug")
84+
message("Build type is not defined, default to Debug")
85+
set(CMAKE_BUILD_TYPE "Debug")
8686
endif()
8787
message(" >>> CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")
8888

8989
# 后台进程安装目录
9090
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
91-
set(EXECUTABLE_INSTALL_DIR "")
91+
set(EXECUTABLE_INSTALL_DIR "")
9292
else()
93-
set(EXECUTABLE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/libexec/${PROJECT_NAME}")
93+
set(EXECUTABLE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/libexec/${PROJECT_NAME}")
9494
endif()
9595

9696
option(ENABLE_SLOTIPC "Enable SlotIPC for compatible with old daemon" ON)
@@ -130,3 +130,19 @@ if(MSVC)
130130
add_compile_options(/utf-8)
131131
endif()
132132
add_subdirectory(src)
133+
134+
# CPack configuration for Windows WiX packaging
135+
if(WIN32 AND ENABLE_WIX)
136+
# Basic CPack settings
137+
set(CPACK_PACKAGE_VENDOR "Uniontech, Inc.")
138+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Deepin Cooperation and Data Transfer Tools")
139+
140+
# Find WiX tools
141+
find_program(WIX_CANDLE_EXE candle PATHS "C:/Program Files/WiX Toolset v6.0/bin" "C:/Program Files (x86)/WiX Toolset v6.0/bin")
142+
find_program(WIX_LIGHT_EXE light PATHS "C:/Program Files/WiX Toolset v6.0/bin" "C:/Program Files (x86)/WiX Toolset v6.0/bin")
143+
144+
if(WIX_CANDLE_EXE AND WIX_LIGHT_EXE)
145+
message(STATUS "WiX Toolset found, enabling CPack WiX generator")
146+
include(CPack)
147+
endif()
148+
endif()

0 commit comments

Comments
 (0)