cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DemonPiggies
Level 7

InstallScript - Devs added/removed file from Component Directory...

So the Devs removed some files and then added new ones, not named the same, and it was completely out of my hands...

This is the code for trying to update the current installation:

function OnMoveData()
.
.
.
begin
.
.
.

//--- If we are updating...
elseif (DetermineIfUpgrade()) then

//--- Set the installation directory to the %ALLUSERSPROFILE%
TARGETDIR = GetCurrentTargetDirectory();

//--- Make sure to select any NEW features
FeatureSelectNew( MEDIA, TRUE );

FeatureReinstall();

//--- Set appropriate StatusEx static text.
Sprintf(sFormattedMsg, @IDS_STATICTEXT_MAINTUI_UPGRADE, @IDS_READABLE_VERSION_STRING);
SetStatusExStaticText(sFormattedMsg);
.
.
.
end


The Devs want to use the Component directory (dir that is dynamically linked to a Component) as a dumping ground for all current files. The code above allows me to get the new files installed but the old ones are still present and I need the gone. Originally I used FeatureSetupTypeSet(MEDIA, "Complete") followed by FeatureRemoveAllInLogOnly() which basically uninstalls the current installation instead of just remove the files that were installed previously, so that the new ones can be installed. So all in all I have to be able to remove the old files within the Component/Feature and install the new ones from the running installer, always in every case.


Assume Deleted file names: OldFile_01
Assume New file names: NewFile_01
Assume Feature name: Feature_01
Assume Component name: Comp_01

OldFile_01 is present in v1.1
NewFile_01 is not present in v1.1

NewFile_01 is present in v1.2
OldFile_01 is not present in v1.2

v1.1 is installed on the system and they want to upgrade to v1.2

OldFile_01 and NewFile_01 are in the same Feature/Component which pulls from the same directory (OldFile was deleted from said dir and NewFIle was added to the said dir)

When user upgrades OldFile_01 needs to be removed from the system and NewFile added, dynamically*.
When user reverts NewFile_01 needs to be removed from the system and OldFile_01 added, dynamically*.

*By "dynamically" I mean that the installer has NO knowledge of the change made pre-build...

tl;drThe Feature in questions contains only 1 Component that holds a large number of config files (sort of). I need to remove all files that are not present in the currently running installer and make sure to add any new files present in that running installer.
Labels (1)
0 Kudos
(1) Reply
DemonPiggies
Level 7

So I've sort of figured out a workaround... and sort encountered another problem.

Part of the issue is that I was using FeatureSelectNew( MEDIA, TRUE ) which only selects new features in the current running installer and then FeatureReinstall() which only plants the files from those already installed features to the system. This is why I had both the old deleted files and the new ones in the same installed directory.

Removed that and figured out that I need to unselect those already installed features in order to remove those installed files and place in the new ones.

I already had a method that came from bastardizing the OnMoveData() method into only uninstalling and handles nothing else. This is mostly so I could support installation logic in the spec... not a great idea but I needed it that way in order to bypass a few things...

So I ended up with this more or less:

//--- Uninstall current version (if failed then abort installation)
if (!PerformActualUninstall()) then
abort;
endif;

//--- Select all current feature
FeatureSetupTypeSet(MEDIA, "Complete");

//--- Set up OS specific features
if(!PrepareInstallation()) then
MessageBox(@IDS_ERROR_PREPARE_INSTALLATION_MSG, SEVERE);
abort;
endif;



So now my problem is that when I can FeatureRemoveAllInLogOnly() and then FeatureTransferData(MEDIA) it completely uninstalls the application even though I later call FeatureSetupTypeSet(MEDIA, "Complete") and then FeatureTransferData(MEDIA) again. By completely uninstall I mean that when I go to uninstall via Add/Remove, it gives me the error stating that it was already uninstalled.

ANY HELP IS APPRECIATED...
0 Kudos