I am creating my own piece of software that aims to automatically upgrade and downgrade Windows software via MSI files.
Being at the testing part of my app I needed something to generate dumb msi files to check both upgrading and downgrading. The problem is that I can’t create msi files via CMake that allow downgrades to be effective. Whenever I try installing an older version, I get the error “A later version of … is already installed. Setup will now exit.”
Here is my CMakeLists.txt file, please note the “if” condition that should enable downgrades but doesn’t:
# Wix will be the MSI generator
set(CPACK_GENERATOR "WIX")
set(CPACK_PACKAGE_NAME "testName")
set(CPACK_PACKAGE_VENDOR "testVendor")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "testing project")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "testdir")
set(CPACK_PACKAGE_EXECUTABLES "program" "testProgram")
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_SOURCE_DIR}/msi")
if (ENABLE_DOWNGRADES)
# WIX properties to allow downgrades
set(CPACK_WIX_PROPERTY
"MajorUpgradeSchedule=afterInstallExecute"
"MajorUpgradeAllowSameVersionUpgrades=yes"
"MajorUpgradeAllowDowngrades=yes"
"DetectNewerInstalledVersion=no"
)
set(CPACK_WIX_UPGRADE_FLAGS "ALLOW_DOWNGRADES")
endif()
# Add the executable and required DLLs to the install target
install(TARGETS program DESTINATION bin)
install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/upgradeguid.txt" DESTINATION bin)
install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/productguid.txt" DESTINATION bin)
include(CPack)
find_program(MSI_GENERATOR cpack.exe)
if(NOT MSI_GENERATOR)
message(FATAL_ERROR "cpack.exe tool not found in PATH")
endif()
add_custom_command(TARGET program POST_BUILD
COMMAND cpack.exe -G WIX
)
Of course, the ENABLE_DOWNGRADES variable is true, so that is not the issue.
I’ve tried tinkering with lots of properties and suggestions from other questions and sources, to no avail.
Any advice? Thank you in advance!
arand0musernam3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.