I want to create an installer where the user selects the program version, and upon choosing the version, the installation path changes. For example:
- if they choose Revit 2023, the path is:
C:\ProgramData\Autodesk\Revit\Addins\2023. - but if they choose
Revit 2022, the path is:C:\ProgramData\Autodesk\Revit\Addins\2022.
Currently, the script is not working as it installs it in the path C:\ProgramData\Autodesk\Revit\Addins without adding the year. Does anyone know how I can fix this?
[Setup]
AppName=AedasHomesAddin
AppVersion=1.0
DefaultDirName={code:GetInstallPath}
DefaultGroupName=AedasHomesAddin
OutputDir=Output
OutputBaseFilename=AedasHomesAddinSetup
Compression=lzma
SolidCompression=yes
DisableDirPage=yes
[Code]
var
SelectedVersion: String;
Page: TInputOptionWizardPage;
function GetSelectedVersion(Param: String): String;
begin
Result := SelectedVersion;
end;
function GetInstallPath(Param: String): String;
begin
// Build the installation path based on the selected year.
Result := ExpandConstant('{commonappdata}\Autodesk\Revit\Addins\' + SelectedVersion);
end;
procedure InitializeWizard;
begin
// Create a custom page for version selection.
Page := CreateInputOptionPage(wpWelcome, 'Select Revit Version', 'Choose the Revit version to install:', 'Select the version:', True, False);
Page.Add('Revit 2019');
Page.Add('Revit 2020');
Page.Add('Revit 2021');
Page.Add('Revit 2022');
Page.Add('Revit 2023');
Page.Add('Revit 2024');
// Initialize SelectedVersion to prevent issues
SelectedVersion := '';
end;
procedure CurPageChanged(CurPageID: Integer);
begin
// Store the selected version
if (CurPageID = Page.ID) and (Page.SelectedValueIndex >= 0) then
begin
case Page.SelectedValueIndex of
0: SelectedVersion := '2019';
1: SelectedVersion := '2020';
2: SelectedVersion := '2021';
3: SelectedVersion := '2022';
4: SelectedVersion := '2023';
5: SelectedVersion := '2024';
end;
end;
end;
[Files]
Source: "C:\Users\jmore\Documentos\Programacion REVIT\C# Jorge\AedasHomesAddin\bin\Debug\AedasHomesAddin.dll"; DestDir: "{code:GetInstallPath}"
Source: "C:\Users\jmore\Documentos\Programacion REVIT\C# Jorge\AedasHomesAddin\bin\Debug\AedasManifest.addin"; DestDir: "{code:GetInstallPath}"
Source: "C:\Users\jmore\Documentos\Programacion REVIT\C# Jorge\AedasHomesAddin\img\AedasHomes.png"; DestDir: "{code:GetInstallPath}"