I have the following CMakeLists.txt
(the only thing in the directory):
cmake_minimum_required(VERSION 3.0.0)
project(CPackUninstallerTest)
set(CPACK_GENERATOR NSIS)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
"DetailPrint \\\"Sleeping...\\\"
Sleep 3000"
)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test.txt" "Some output\n")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/test.txt" TYPE DATA)
include(CPack)
Running cmake
and cpack
works fine, and .../build/CPackUninstallerTest-0.1.1-win64.exe
is generated.
Running the installer works as expected:
And running the uninstaller (Uninstall.exe
in the install directory) also works, where the sleep takes three seconds:
However, this uninstall window does not show up if I try to install on top of an existing installation. After clicking Yes here:
That window goes away for three seconds (as it uninstalls) before the new installer runs.
This is a terrible user experience and results in them re-running the installer while waiting for the hidden uninstaller, causing confusing results.
How do I configure NSIS or CMake/CPack to show the uninstaller progress bar when using CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL
and re-installing?
Your issue could not be solved with NSIS interfaces of CMake.
I had a similar problem with CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL
. The user could not install it again when uninstallation run manually.
The problem here is that manually running the uninstaller does not delete the install flag from windows registry keys.
My recommendation is that you can create your NSIS script by using NSIS template script of CMake. And you can add remove command easily to uninstaller section of new script.
And then you can give the new script as template to CMake.