yefchak
Posts: 16
Joined: Fri Oct 11, 2013 10:44 pm

How to build two versions with separate app settings

Hi folks,

I would like to create two versions of my application with a single build. They would differ in only the following ways:
1. a setting in my appsettings.json file is "true" in one case and "false" in another
2. the app shortcuts have different names (e.g., MyApp and MyApp SafeMode)

Is this possible? How can I do it.

If not... what's the best alternate approach?
Thanks
Liviu
Posts: 1419
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: How to build two versions with separate app settings

Hello,

If you want to generate two separate installer packages with different appsettings.json values and shortcut names, this cannot be done from a single build configuration.

A build generates one package with one set of resources and values.

The recommended approach is to create two build configurations in the same .AIP project and use per-build values for the differences between them. This way you still maintain only one project, but each build produces the corresponding application variant.

For example:

Code: Select all

Build 1:
SafeMode = false
Shortcut = MyApp

Build 2:
SafeMode = true
Shortcut = MyApp SafeMode
If by “single build” you mean a single installer that contains both variants, that could be designed differently, for example using features/conditions, but it would be one package installing selectable variants rather than two separate installers.

Let me know if you have any questions.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
yefchak
Posts: 16
Joined: Fri Oct 11, 2013 10:44 pm

Re: How to build two versions with separate app settings

Thank you. I'm not yet familiar enough with the features "per-build value" or "features" and "conditions". When I looked at the documentation for features, I thought what I would need was only available with the Enterprise edition of Advanced Installer. (I have the pro edition). Looking at the documentation for per-build values, that seems more like what I need, except I don't yet see how to use this feature to create what I want.

Let me try to state more fully exactly what I'm looking for, and maybe you can tell me what would be the easiest approach.

1. I want a single build to create two versions of my project, resulting in two separate setup.exe installers.
1.a. If (1) is not possible, I could perhaps create two Advanced Installer projects, but they I'd have to make sure all their settings are kept in sync.

2. The projects should be identical except for (1) a true vs. false value in appsettings.json, and (2) the program name (at least as displayed in the desktop icon)

Thank you,
--George
Liviu
Posts: 1419
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: How to build two versions with separate app settings

Hello George,

Thank you for the additional details.

The only limitation in your case is that Advanced Installer's built-in JSON file editing support requires the Enterprise edition. Therefore, for the scenario you described, the easiest and fully supported approach would be to upgrade to Enterprise.

You do not need to maintain two separate Advanced Installer projects for this. Multiple Builds are available in the Professional edition, so you can keep everything in a single .AIP project.

1. You would create two build configurations in the Builds page, for example:
builds page.png
builds page.png (75.06 KiB) Viewed 1325 times

Each build generates its own setup.exe, while all the common files and settings remain in the same project. You can then use Build All to generate both packages in one operation.

2. For the differences between the builds, you can use properties with Per-Build Values, for example the MULTIPLEBUILDS property:
multiple builds property.png
multiple builds property.png (123.48 KiB) Viewed 1325 times

3. For the appsettings.json change, with the Professional version you could use a small PowerShell custom action that updates the required JSON value based on the property. However, this would be more difficult to implement and maintain without using our predefined JSON support.

With our predefined support, you can use the property directly as shown below:
json update.png
json update.png (133.17 KiB) Viewed 1325 times
and (2) the program name (at least as displayed in the desktop icon)
4. For this you can create a new property with per builds values, as shown below:
appname prop.png
appname prop.png (115.28 KiB) Viewed 1325 times

Then, when creating the shortcut, you can use this property in the shortcut Name field:
shortcut.png
shortcut.png (172.63 KiB) Viewed 1325 times

You can even use the property in the Product Details page for the Name field.

I have attached a sample project, saved with the Enterprise edition because it uses the JSON update support.
sample.aip
(27.42 KiB) Downloaded 19 times

Hope this helps! Let us know if you have any questions.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
yefchak
Posts: 16
Joined: Fri Oct 11, 2013 10:44 pm

Re: How to build two versions with separate app settings

Thank you. Unfortunately none of what you describe works without the Enterprise editing, so I plan to do everything in a PowerShell script.

Unfortunately this isn't working yet either, because I'm unable to get the [APPDIR] path into my script.
In the Custom Actions pane, I have create a PowerShellScriptInline action.
For "Parameter values:" I have entered exactly the following

Code: Select all

[IsViewerBuild] [APPDIR]
Then in the script itself I have

Code: Select all

Param($isViewerBuild, $appdir)
$jsonPath = "$appdir" + "\appsettings.json"
My IsViewerBuild is passed correctly, but $appdir is always passed as only "C:\Program"

How can I get the true target application path into my script?

Thank you
Liviu
Posts: 1419
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: How to build two versions with separate app settings

Hello,

If the path contains spaces, please enclose the property in quotation marks:

[IsViewerBuild] "[APPDIR]"

Let me know if that helped.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”