end2endzone / ShellAnything

ShellAnything is a C++ open-source software which allow one to easily customize and add new options to *Windows Explorer* context menu. Define specific actions when a user right-click on a file or a directory.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to generate the msi installer?

arathburgos05 opened this issue · comments

Describe the bug
This is not a bug. I only need to generate the msi installer, I'm not very familiarized with Visual Studio env.

To Reproduce
I followed the steps mentioned here:
https://github.com/end2endzone/ShellAnything/blob/master/INSTALL.md

I'm trying with tag/0.8.0. I'm using Win10 x64, Visual Studio 2022 and I enabled the check for Desktop development with C++. I installed FireGiant.HeatWave.Dev17.vsix instead of WiX Toolset idk if this has some impact.
There are some errors/warnings during build_all_release.bat execution.
image
Step 1. $ git clone https://github.com/end2endzone/ShellAnything.git & cd ShellAnything & git checkout tags/0.8.0 & cd .\ci\windows & build_all_release.bat → Log: build_all_release.log
Step 2. $ Look for any msi installer in all path:
image

I tried also playing with build targets in Visual Studio IDE but I got these errors:
image
build_visual.log

Expected behavior
To have the msi installer.

Screenshots
I already added screenshots in previous sections.

Environment

  • OS: Win64
  • Version 21H2
  • CMake: 3.27.4
  • Visual Studio: 2022

Additional context
Not applicable.

Hi. Thank you for showing interest for ShellAnything.

I took a while to look at all the good documentation that you provided for this issue. Unfortunately, I do not understand why you would have issues as such. I never seen compilation issue that looks like that. I will try my best to interpret them.

The line which "builds the msi" is in install_shellanything.bat, line 63. You can also build the installer manually from Visual Studio by building the PACKAGE project. This is a Visual Studio Project generated by cmake. If you are not using the official msi installer, its because you want to build your own after you made some modifications. Please note that running build_all_release.bat multiple times may result in unexpected errors. It was not written/tested/designed to be run multiple times. I do not say that this is what you did. I just never tried. The expected way would be to run build_all_release.bat once, modify your code and then build the PACKAGE project from within Visual Studio.

According to your first screenshot, you don't seem to be missing C++ packages for building the project. According to your first screenshot, you reached the "installation" phase (lines starting with -- Installing:). It means that compilation is successful. CMake is complaining about file README.md that cannot be "installed". Installing this file from cmake literally means "to copy from the source directory to the target installation directory". It also states that the file exists. Could your file be locked in some ways ? Is README.md opened in a live editor ? I am quite puzzle about this. What could be preventing cmake from copy pasting this file...

The following lines in red are the result of the README.md failure. I do not think they are meaningful. When Visual Studio executes pre/post build events, it invokes cmake through Batch commands. When CMake returns an error, Visual Studio usually spits out the Batch commands used to invoke cmake.

Your last screenshot with the error LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library is because you mixed DEBUG and RELEASE builds. ShellAnything has multiple dependency projects (RapidAssist, tinyxml2, glog, libmagic, zlib). These are not updated when you build from Visual Studio. ShellAnything's binaries and all dependencies must be compiled with the same compiler and runtimes. Debug and Release builds do not use the same runtimes DLL which is why you get all these errors. For example, if you first build with build_all_release.bat, open the project in visual studio and switch to the DEBUG configuration and build. You get an error because you try to link ShellAnything's debug binaries with RapidAssist's release binaries.

I am unfamiliar with HeatWave. A quick looks tell me that its an extension for Visual Studio. Does it depends on Wix Toolset to work ? If you do install HeatWave, does it also installs Wix Toolset ? I would assume that Wix Toolset must be installed as an independent step for HeatWave to work correctly. I doubt HeatWave is also bundling Wix Toolset in its installer. If Wix Toolset is available on your system, you should have a WIX environment variables created which value is set to Wix installation directory. For example:

C:\Windows\system32>set wix
WIX=C:\Program Files (x86)\WiX Toolset v3.11\

When first configuring ShellAnything's project, CMake should print the following line in the output console:

-- Found WIX: C:/Program Files (x86)/WiX Toolset v3.11/bin/candle.exe  

For more reference, you can look at the official build log from https://ci.appveyor.com/project/end2endzone/shellanything. The recipe used on AppVeyor is described in file appveyor.yml. It should match what is in build_all_release.bat. You could try to compare your logs from the official logs to get more hints if something is missing/wrong/unexpected/etc.

TD;DR

I think installing Wix Toolset is you best chance to resolve the issue. You should try install Wix Toolset, purge your source directory, and rebuild. If the above does not work, update the issue and I will try to help you from there.

@end2endzone

Thank you for your complete response. I'll take a look on it in a few.

Meanwhile, I have a problem that idk how to solve it. It's related to this PR, in fact, it's the main reason why I want to edit installer. Maybe you know an easy way to fix it.

Basically I'm using this command to install it using ShellAnything MSI:
Start-Process -Wait -FilePath msiexec -ArgumentList /i, ShellExtension-0.8.0-win64.msi, /qn, /l*v, install.log -PassThru;

and this one to uninstall it:
Start-Process -Wait -FilePath msiexec -ArgumentList /x, ShellExtension-0.8.0-win64.msi, /qn, /l*v, install.log -PassThru;

It's working as expected. However, when it is installed first time. It creates general samples in ShellAnything folder showing them in right click:
image

I know that this can be easily deleted with my own installer. The problem is that those files are not created immediately (I guess).
[C:\Users\USERNAME\ShellAnything]
image

I think that they are created once we do right click first time or idk what is the exactly condition to create them. I tried also install, uninstall and install it again (deleting ShellAnything folder). But it didn't work.

As I mentioned It can't be replicated on the same computer twice (Those demos files are copied only fist time, I think I'll use a virtual machine with recovery point to replicate It). I know that this is not an issue at all. My own installer basically installs your app in background and then copy my xml to ShellAnything folder.

The expected behavior from my side would be to skip copying the defaults xml files on first installation (maybe adding a register option or knowing when demos are copied first time).

Do you know if there is any register key that I can add to prevent to copy demos in new installation? (or maybe a flag during installation)
Do you know when those files are created first time? (I'm sure that at the end of the installation not).

Thanks again for your attention.

Update: This issue (about ShellAnything creation folder first time) was solved setting this key HKEY_CURRENT_USER\SOFTWARE\ShellAnything\0.8.0\first_run to false. I discovered it reading your code.

@end2endzone

I read carefully your last comment. And you are right.

The line which "builds the msi" is in install_shellanything.bat, line 63. You can also build the installer manually from Visual Studio by building the PACKAGE project. This is a Visual Studio Project generated by cmake. If you are not using the official msi installer, its because you want to build your own after you made some modifications. Please note that running build_all_release.bat multiple times may result in unexpected errors. It was not written/tested/designed to be run multiple times. I do not say that this is what you did. I just never tried. The expected way would be to run build_all_release.bat once, modify your code and then build the PACKAGE project from within Visual Studio.

Yes, I only ran build_all_release.bat once. It's good to know that this should be run only once. The changes that I wanted to do are in my last comment (solved). Anyways, I would like to learn how to generate the MSI installer to play with your code :)

According to your first screenshot, you don't seem to be missing C++ packages for building the project. According to your first screenshot, you reached the "installation" phase (lines starting with -- Installing:). It means that compilation is successful. CMake is complaining about file README.md that cannot be "installed". Installing this file from cmake literally means "to copy from the source directory to the target installation directory". It also states that the file exists. Could your file be locked in some ways ? Is README.md opened in a live editor ? I am quite puzzle about this. What could be preventing cmake from copy pasting this file...
The following lines in red are the result of the README.md failure. I do not think they are meaningful. When Visual Studio executes pre/post build events, it invokes cmake through Batch commands. When CMake returns an error, Visual Studio usually spits out the Batch commands used to invoke cmake.

For the moment we can ignore the error related to README.md. I have to mention that I didn't opened it locally. Maybe It was locked as you said by a previous step. However, I really don't need it for my purposes.
Edit: Your CI/CD seems to have a similar error https://ci.appveyor.com/project/end2endzone/shellanything#L2828

Your last screenshot with the error LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library is because you mixed DEBUG and RELEASE builds. ShellAnything has multiple dependency projects (RapidAssist, tinyxml2, glog, libmagic, zlib). These are not updated when you build from Visual Studio. ShellAnything's binaries and all dependencies must be compiled with the same compiler and runtimes. Debug and Release builds do not use the same runtimes DLL which is why you get all these errors. For example, if you first build with build_all_release.bat, open the project in visual studio and switch to the DEBUG configuration and build. You get an error because you try to link ShellAnything's debug binaries with RapidAssist's release binaries.

I was using DEBUG instead of RELEASE this caused the Visual Studio errors. It was solved using RELEASE (because I ran build_all_release.bat). (Thanks for clarify it. I'm not too familiarized with Visual Studio)

I am unfamiliar with HeatWave. A quick looks tell me that its an extension for Visual Studio. Does it depends on Wix Toolset to work ? If you do install HeatWave, does it also installs Wix Toolset ? I would assume that Wix Toolset must be installed as an independent step for HeatWave to work correctly. I doubt HeatWave is also bundling Wix Toolset in its installer. If Wix Toolset is available on your system, you should have a WIX environment variables created which value is set to Wix installation directory. For example: [...]

My bad, because I haven't used WIX TOOLSET it was confused for me to install it from official website (at the end I went to the git repo and downloaded the binary), then I added it to path (env vars) and I got your output:

C:\Windows\system32>set wix
WIX=C:\Program Files (x86)\WiX Toolset v3.11\

For that reason I installed HeatWave instead of WIX TOOLSET. And not, the first one doesn't install WIX automatically (so It was completely unnecessary from my side).

-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found WIX: C:/Program Files (x86)/WiX Toolset v3.11/bin/candle.exe
-- Could NOT find NSIS (missing: NSIS_MAKE)
-- Could NOT find GRIP (missing: GRIP_PROGRAM)
-- Downloading exprtk package from https://github.com/ArashPartow/exprtk/archive/master.zip

Do you know if NSIS and GRIP are necessary to generate the MSI Installer? or How can I install them?
image

For more reference, you can look at the official build log from https://ci.appveyor.com/project/end2endzone/shellanything. The recipe used on AppVeyor is described in file appveyor.yml. It should match what is in build_all_release.bat. You could try to compare your logs from the official logs to get more hints if something is missing/wrong/unexpected/etc.

It will be useful. From here I think that I can continue investigating. I really appreciate your time reading my comments and proposing solutions.

Now I need to investigate how to generate the MSI Installer. These are mi new logs:
build_all_release2.log
PACKAGE_rebuild2.log

It seems to work but MSI installer is not being generated :(
image

These are the steps that I followed: First I verified my configuration:
image

Then I clicked on build:
image

Do am I forgetting another step to generate the MSI Installer?

Regards.

Do you know if NSIS and GRIP are necessary to generate the MSI Installer? or How can I install them?

NSIS is not required for the project. The NSIS warning should not be displayed. I have created #132 to specifically deal with this message.

GRIP is optional for the project. That is a tool that converts the documentation files from Markdown (*.md) to HTML. If you do have it installed, temporary HTML files are generated and used in the MSI. If GRIP is not installed/available, the MSI shortcuts shall link to the original *.md files. However, its been a long time since I have tested without GRIP and the feature might be broken.

README.md
Your 2nd build log (build_all_release2.log) is still unable to install README.md. Since you only want to test your changes and the installer, you could remove the cmake command that tries to install the file. Just remove ${CMAKE_SOURCE_DIR}/README.md from CMakeLists.txt at line 365. Your build should stop being interrupted with the error and MSI should hopefully be generated.

The expected way would be to run build_all_release.bat once, modify your code and then build the PACKAGE project from within Visual Studio.

I am sorry. I think my explanations were incomplete. From PACKAGE_rebuild2.log, I see that you actually tried to build PACKAGE. However, is was skipped based on the line 15>------ Skipped Rebuild All: Project: PACKAGE ------. This is an annoying Visual Studio thing. What you actually did is build "all PACKAGE dependencies" but VS has skipped PACKAGE because it was not selected to be build in the "Release X64" configuration. This might be a problem because the VS project is generated by cmake. I do not know exactly.

Here how to solve it with Visual Studio 2019. I am expecting to have the same steps with VS2022:

  1. Open the Build menu from the top menu bar, and select Configuration Manager.... A window will open.
  2. Make sure that you select Release configuration and x64 platform.
  3. In the bottom section, look for PACKAGE project and make sure the Build checkbox is checked.
  4. Right-click PACKAGE again in the Solution Explorer and select Build.

The process is described here: https://stackoverflow.com/questions/65225192/certain-projects-in-visual-studio-refuse-to-build-even-when-i-attempt-to-build

If that does not work, you can also "force build PACKAGE":

  1. Build PACKAGE as the previous steps
  2. Right-click PACKAGE.
  3. Under Project Only menu, select Build Only PACKAGE.

You should then see the following output:

Build started...
1>------ Build started: Project: PACKAGE, Configuration: Release x64 ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1967,5): warning : The referenced project 'Solution Items (dummy)' does not exist.
1>Done building project "ALL_BUILD.vcxproj".
1>CPack: Create package using ZIP
1>CPack: Install projects
1>CPack: - Install project: ShellAnything [Release]
1>CPack: Create package
1>CPack: - package: D:/Projets/Programmation/Cpp/ShellAnything/ShellAnything-release/build/ShellAnything-0.8.0-win64.zip generated.
1>CPack: Create package using WIX
1>CPack: Install projects
1>CPack: - Install project: ShellAnything [Release]
1>CPack: Create package
1>CPack: - package: D:/Projets/Programmation/Cpp/ShellAnything/ShellAnything-release/build/ShellAnything-0.8.0-win64.msi generated.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

and the MSI should be in your build directory.

Keep me posted about your progress.

@end2endzone

Let me try. I'll update this comment with my results.

Regards :)

Are u still having an issue building the installer ?

@end2endzone
I forgot to provide a response. All is working properly.
We can close this issue now. Thanks :)