Skip to content

Commit 2460be9

Browse files
committed
Implements minimumUpdateVersion for MSI for multiple instance setups.
1 parent 1fd7987 commit 2460be9

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/com/inet/gradle/setup/msi/WxsFileBuilder.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void build() throws Exception {
145145
Element update = getOrCreateChild( product, "MajorUpgrade" );
146146
addAttributeIfNotExists( update, "AllowDowngrades", "yes" );
147147

148-
addMinimumVersionCheck();
148+
addMinimumVersionCheck( getGuid( "UpgradeCode" ), 0 );
149149
}
150150

151151
// Directory
@@ -235,24 +235,26 @@ private void registerSchemeDefinition( ProtocolHandler handler ) {
235235

236236
/**
237237
* Add a minimum version for update check if set.
238+
* @param upgradeCode the GUID of the upgrade code
239+
* @param instance the instance number
238240
*/
239-
private void addMinimumVersionCheck() {
241+
private void addMinimumVersionCheck( String upgradeCode, int instance ) {
240242
String version = setup.getMinimumUpdateVersion();
241243
String message = setup.getMinimumUpdateMessage();
242244
if( version != null && message != null ) {
243245
// https://stackoverflow.com/questions/65787694/wix-prevent-only-certain-older-versions-from-being-updated
244246

245-
Element upgrade = getOrCreateChildById( product, "Upgrade", getGuid( "UpgradeCode" ) );
246-
Element upgradeVersion = getOrCreateChildByKeyValue( upgrade, "UpgradeVersion", "Property", "UNSUPPORTED_UPGRADE_VERSION_FOUND" );
247+
Element upgrade = getOrCreateChildById( product, "Upgrade", upgradeCode );
248+
Element upgradeVersion = getOrCreateChildByKeyValue( upgrade, "UpgradeVersion", "Property", "UNSUPPORTED_UPGRADE_VERSION_FOUND_" + instance );
247249
addAttributeIfNotExists( upgradeVersion, "OnlyDetect", "yes" );
248250
addAttributeIfNotExists( upgradeVersion, "Maximum", version );
249251
addAttributeIfNotExists( upgradeVersion, "IncludeMaximum", "no" );
250252

251-
Element customAction = getOrCreateChildByKeyValue( product, "CustomAction", "Id", "UpgrateFromVersionNotSupported" );
253+
Element customAction = getOrCreateChildByKeyValue( product, "CustomAction", "Id", "UpgrateFromVersionNotSupported_" + instance );
252254
addAttributeIfNotExists( customAction, "Error", message );
253255

254-
Element action = addCustomActionToSequence( "UpgrateFromVersionNotSupported", false, "FindRelatedProducts", true, null );
255-
action.setTextContent( "UNSUPPORTED_UPGRADE_VERSION_FOUND" );
256+
Element action = addCustomActionToSequence( "UpgrateFromVersionNotSupported_" + instance, false, "FindRelatedProducts", true, null );
257+
action.setTextContent( "UNSUPPORTED_UPGRADE_VERSION_FOUND_" + instance );
256258
}
257259
}
258260

@@ -1427,6 +1429,8 @@ private void addMultiInstanceTransforms() throws IOException {
14271429
Element upgradeVersion = getOrCreateChildByKeyValue( upgrade, "UpgradeVersion", "Property", "WIX_UPGRADE_DETECTED_" + i );
14281430
addAttributeIfNotExists( upgradeVersion, "Minimum", "0.0.0.0" );
14291431
addAttributeIfNotExists( upgradeVersion, "MigrateFeatures", "yes" );
1432+
1433+
addMinimumVersionCheck( guid, i );
14301434
}
14311435
Element executeSequence = getOrCreateChild( product, "InstallExecuteSequence" );
14321436
Element removeExistingProducts = getOrCreateChild( executeSequence, "RemoveExistingProducts" );

testBuilds/setupBuilder.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ setupBuilder {
3333
application = "Setup Builder Test"
3434
description = 'Build a test Programm.'
3535
icons = "test-icon.icns"
36+
vendor = 'Sample Company Inc.'
3637

3738
licenseFile "license_en.txt"
3839
licenseFile {
@@ -57,7 +58,7 @@ setupBuilder {
5758
}
5859
service {
5960
displayName = "i-net TestLaunch Server"
60-
id = "helpdesk"
61+
id = "testservice"
6162
}
6263
version = "3.0"
6364
minimumUpdateVersion "2.5"
@@ -97,6 +98,7 @@ msi{
9798
languages = ["en-us"]
9899
//external file("fragmentDlg.wxs")
99100
//wxsTemplate = "template.wxs"
101+
multiInstanceCount = 10
100102
}
101103

102104
dmg.dependsOn jar

0 commit comments

Comments
 (0)