@@ -616,6 +616,89 @@ begin
616616 Result := True;
617617end ;
618618
619+ type
620+ UpgradeRing = (urUnconfigured, urNone, urFast, urSlow);
621+
622+ function GetConfiguredUpgradeRing (): UpgradeRing;
623+ var
624+ ResultCode: integer;
625+ ResultString: ansiString;
626+ begin
627+ Result := urUnconfigured;
628+ if ExecWithResult(' gvfs.exe' , ' config upgrade.ring' , ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode, ResultString) then begin
629+ if ResultCode = 0 then begin
630+ ResultString := AnsiLowercase(Trim(ResultString));
631+ Log(' GetConfiguredUpgradeRing: upgrade.ring is ' + ResultString);
632+ if CompareText(ResultString, ' none' ) = 0 then begin
633+ Result := urNone;
634+ end else if CompareText(ResultString, ' fast' ) = 0 then begin
635+ Result := urFast;
636+ end else if CompareText(ResultString, ' slow' ) = 0 then begin
637+ Result := urSlow;
638+ end else begin
639+ Log(' GetConfiguredUpgradeRing: Unknown upgrade ring: ' + ResultString);
640+ end ;
641+ end else begin
642+ Log(' GetConfiguredUpgradeRing: Call to gvfs config upgrade.ring failed with ' + SysErrorMessage(ResultCode));
643+ end ;
644+ end else begin
645+ Log(' GetConfiguredUpgradeRing: Call to gvfs config upgrade.ring failed with ' + SysErrorMessage(ResultCode));
646+ end ;
647+ end ;
648+
649+ function IsConfigured (ConfigKey: String): Boolean;
650+ var
651+ ResultCode: integer;
652+ ResultString: ansiString;
653+ begin
654+ Result := False
655+ if ExecWithResult(' gvfs.exe' , Format(' config %s' , [ConfigKey]), ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode, ResultString) then begin
656+ ResultString := AnsiLowercase(Trim(ResultString));
657+ Log(Format(' IsConfigured(%s): value is %s' , [ConfigKey, ResultString]));
658+ Result := Length(ResultString) > 1
659+ end
660+ end ;
661+
662+ procedure SetIfNotConfigured (ConfigKey: String; ConfigValue: String);
663+ var
664+ ResultCode: integer;
665+ ResultString: ansiString;
666+ begin
667+ if IsConfigured(ConfigKey) = False then begin
668+ if ExecWithResult(' gvfs.exe' , Format(' config %s %s' , [ConfigKey, ConfigValue]), ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode, ResultString) then begin
669+ Log(Format(' SetIfNotConfigured: Set %s to %s' , [ConfigKey, ConfigValue]));
670+ end else begin
671+ Log(Format(' SetIfNotConfigured: Failed to set %s with %s' , [ConfigKey, SysErrorMessage(ResultCode)]));
672+ end ;
673+ end else begin
674+ Log(Format(' SetIfNotConfigured: %s is configured, not overwriting' , [ConfigKey]));
675+ end ;
676+ end ;
677+
678+ procedure SetNuGetFeedIfNecessary ();
679+ var
680+ ConfiguredRing: UpgradeRing;
681+ RingName: String;
682+ TargetFeed: String;
683+ FeedPackageName: String;
684+ begin
685+ ConfiguredRing := GetConfiguredUpgradeRing();
686+ if ConfiguredRing = urFast then begin
687+ RingName := ' Fast' ;
688+ end else if (ConfiguredRing = urSlow) or (ConfiguredRing = urNone) then begin
689+ RingName := ' Slow' ;
690+ end else begin
691+ Log(' SetNuGetFeedIfNecessary: No upgrade ring configured. Not configuring NuGet feed.' )
692+ exit;
693+ end ;
694+
695+ TargetFeed := Format(' https://pkgs.dev.azure.com/microsoft/_packaging/VFSForGit-%s/nuget/v3/index.json' , [RingName]);
696+ FeedPackageName := ' Microsoft.VfsForGitEnvironment' ;
697+
698+ SetIfNotConfigured(' upgrade.feedurl' , TargetFeed);
699+ SetIfNotConfigured(' upgrade.feedpackagename' , FeedPackageName);
700+ end ;
701+
619702// Below are EVENT FUNCTIONS -> The main entry points of InnoSetup into the code region
620703// Documentation : http://www.jrsoftware.org/ishelp/index.php?topic=scriptevents
621704
@@ -673,6 +756,7 @@ function PrepareToInstall(var NeedsRestart: Boolean): String;
673756begin
674757 NeedsRestart := False;
675758 Result := ' ' ;
759+ SetNuGetFeedIfNecessary();
676760 if ConfirmUnmountAll() then
677761 begin
678762 if ExpandConstant(' {param:REMOUNTREPOS|true}' ) = ' true' then
0 commit comments