x-tools/CMake/sak_script_generate_msix.cmake
2024-03-19 14:32:36 +08:00

45 lines
1.6 KiB
CMake
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# * argTarget 构建目标
# * argZipFile zip压缩文件绝对路径
# * argPacketName 包/标识/名称
# * argPacketVersion 版本
# * argPacketSuffix 包/标识/名称后缀
set(cooked_version "${argPacketVersion}.0")
set(output_name "${argPacketName}_${cooked_version}_${argPacketSuffix}")
set(old_text ${argTarget}.zip)
set(new_text ${argZipFile})
execute_process(
COMMAND
powershell -Command
"(Get-Content template.xml) -replace '${old_text}', '${new_text}' | Set-Content template.xml")
set(old_text "${argTarget}.msix")
set(new_text "${output_name}.msix")
execute_process(
COMMAND
powershell -Command
"(Get-Content template.xml) -replace '${old_text}', '${new_text}' | Set-Content template.xml")
set(old_text "${argTarget}.xml")
set(new_text "${output_name}.xml")
execute_process(
COMMAND
powershell -Command
"(Get-Content template.xml) -replace '${old_text}', '${new_text}' | Set-Content template.xml")
set(old_text "${argTarget}Version")
set(new_text "${cooked_version}")
execute_process(
COMMAND
powershell -Command
"(Get-Content template.xml) -replace '${old_text}', '${new_text}' | Set-Content template.xml")
# * 执行打包命令要将MsixPackagingTool.exe设置为以管理员身份运行否则可能会不成功
# * powershell -Command "MsixPackagingTool.exe create-package --template template.xml"
execute_process(
COMMAND powershell -Command "MsixPackagingTool.exe create-package --template template.xml"
OUTPUT_VARIABLE tmp
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "Packing finished: ${tmp}")