activescott / lessmsi

A tool to view and extract the contents of an Windows Installer (.msi) file.
https://lessmsi.activescott.com
MIT License
1.29k stars 150 forks source link

Add an overwrite option #167

Open Maxim-Mazurok opened 3 years ago

Maxim-Mazurok commented 3 years ago

Describe the bug Please, add "overwrite" files in the destination option. Instead of adding *.duplicate1 files, I'd like lessmsi to overwrite files in the destination.

To Reproduce Steps to reproduce the behavior:

  1. Use lessmsi to extract some msi
  2. Use lessmsi to extract the same msi
  3. Observe *.duplicate1 files, and no option to overwrite instead

Expected behavior I'd like to have an option to overwrite dest files

Desktop (please complete the following information):

activescott commented 3 years ago

Thanks @Maxim-Mazurok. CLI or GUI?

If you or or anyone else is interested in contributing let me know. Happy to discuss or help guide in any way at all.

Maxim-Mazurok commented 3 years ago

I'm using CLI, thanks in advance :)

mega5800 commented 1 month ago

Hello @Maxim-Mazurok.

Recently, new extraction commands “xfo” and “xfr” were added to the LessMSI CLI. These commands extract all the MSI files into one folder location without the original folder structure and either overwrites files with identical names (xfo) or renames them with a count suffix (xfr).

Perhaps, these commands will help you achieve your goal. If not, I’d love to take care of this ticket.

Thank you.

Maxim-Mazurok commented 1 month ago

I probably need to preserve folder structure, I'm unpacking nodejs.msi to use as a local install, and I would imagine that structure matters since some files might reference other files from installation by relative path. Thanks @mega5800 :)

mega5800 commented 1 month ago

@Maxim-Mazurok Thank you for your response, I understand your use case much better now.

I'd like to take care of this ticket, and will be grateful if you could update your ticket description using the latest version of LessMSI.

There years have passed since this ticket was opened, and the latest state of this feature would be beneficial for my dev work.

@activescott Can you please assign this ticket to me?

Thank you.

Maxim-Mazurok commented 1 month ago

No worries! I've updated description and tried with the latest release, the behaviour is the same.

Here's an extract from our cmd script that uses lessmsi:

:: manually make sure you have the latest release of lessmsi in %CI_FOLDER%

:: remove old lessmsi
if exist %CI_FOLDER%\lessmsi rmdir /s /q %CI_FOLDER%\lessmsi

:: extract lessmsi.zip
powershell -NoExit -Command "Get-ChildItem (Join-Path %CI_FOLDER% lessmsi-*.zip) | foreach {Expand-Archive $_.FullName -DestinationPath (Join-Path %CI_FOLDER% lessmsi)}; exit;"

:: remove old NodeJS local install
if exist %CI_FOLDER%\nodejs rmdir /s /q %CI_FOLDER%\nodejs

:: extract NodeJS msi ot create a portable/local installation of node
%CI_FOLDER%\lessmsi\lessmsi x %_node_msi_path% %CI_FOLDER%\nodejs\ >NUL

:: remove new lessmsi
rmdir /s /q %CI_FOLDER%\lessmsi

:: set PATH to use new node
set "PATH=%CI_FOLDER%\nodejs\SourceDir\nodejs;%PATH%"

Hope this helps, cheers!

activescott commented 1 month ago

@mega5800 Can you please look at #187 and see if it is related. I suspect that it is. I left a comment explaining what I think is a good solution there after investigating. Essentially in some cases 64bit and 32bit dlls have the same name and in the current logic resolve to the same root path and end up appearing to be duplicates, but they're not actually duplicates. They just have a duplicate name. So if we were to overwrite those, you might get 32bit or 64bit version (whichever happened to be extracted last). The fix is outlined in my comment and is just a way to make that root directory unique.

I bet if we fix that one, there wouldn't be duplicate files anymore for this one, and I remember seeing some other issues that I thought were related to that one.

Maxim-Mazurok commented 1 month ago

Well, in my case I'm just extracting msi multiple times into the same folder, when we're running our CI scripts on local. In CI it wouldn't be an issues because it creates new temp folder for each build. But on local we use the same folder on each run.

But yeah, I see where you're coming from, you probably don't really know if that's a file that was left by a previous extraction, or is it a different bittness DLL.

TBH it's not a big deal for me to clear the folder manually, it's just that I was surprised that lessmsi has this extra logic to preserve old files and add duplicate files, now I see there's sorta reason behind it.

activescott commented 1 month ago

Thanks for the feedback @Maxim-Mazurok Sounds like you would still like the overwrite option (in an ideal world). I guess I'd like to see #187 resolved first as overwrite + that bug might leave some unexpected results.