2
votes

I have an XML file with some tags like names of DLL files.

I want a Inno Setup script code to install only files stated in the XML file (I can read from XML file).

My question is: How can I embed all DLL files and according to the XML file, I only install only the required files.

The idea I just need one XML for each release, and I never change the DLL files.

1
One question at a time please. You have at least three question here 1) Parsing XML file. 2) Programmatically installing DLL based on some configuration. 3) Embedding all dll files. - Martin Prikryl
Only the embded how to work with them - user253008
So do you have a list of DLLs to embed? Or do you want to automatically include all *.dll from some directory and then on install-time decide what files to install? - Martin Prikryl
I have files dll1.dll and dll2.dll and I need my script to read the xml and then install only what in xml (I know how to work with xml), but I do not know how to copy and how to embed files - user253008
where can I store dll1 and dll2 in the setup package ? - user253008

1 Answers

1
votes

Use the Check parameter to programmatically decide if a certain file should be installed:

[Files]
Source: "Dll1.dll"; DestDir: "{app}"; Check: ShouldInstallDll1
Source: "Dll2.dll"; DestDir: "{app}"; Check: ShouldInstallDll2

[Code]

function ShouldInstallDll1: Boolean;
begin
  Result := ???;
end;

function ShouldInstallDll2: Boolean;
begin
  Result := ???;
end;

If it better suits your logic, you can also use a single "check" function and use the CurrentFileName magic variable, to test, if the file being installed, is the one you want to really install:

[Files]
Source: "Dll1.dll"; DestDir: "{app}"; Check: ShouldInstallDll
Source: "Dll2.dll"; DestDir: "{app}"; Check: ShouldInstallDll

[Code]

var
  FileToInstall: string;

function InitializeSetup(): Boolean;
begin
  FileToInstall := ??? { 'Dll1.dll' or 'Dll2.dll' based on the XML file }
  Result := True;
end;

function ShouldInstallDll: Boolean;
var
  Name: string;
begin
  Name := ExtractFileName(CurrentFileName);
  Result := (CompareText(Name, FileToInstall) = 0);
end;

The latter approach can be used, even if you pack files using a wildcard:

[Files]
Source: "*.dll"; DestDir: "{app}"; Check: ShouldInstallDll