@@ -100,23 +100,8 @@ export class DotnetGlobalSDKLinuxInstallerResolver
100100 }
101101 }
102102
103- private async ValidateVersionFeatureBand ( version : string , existingGlobalDotnetVersion : string )
103+ private async VerifyNoConflictInstallTypeExists ( supportStatus : DotnetDistroSupportStatus , fullySpecifiedDotnetVersion : string ) : void
104104 {
105-
106-
107- }
108-
109- public async ValidateAndInstallSDK ( fullySpecifiedDotnetVersion : string ) : Promise < string >
110- {
111- // Verify the version of dotnet is supported
112- if ( ! ( await this . distroSDKProvider . isDotnetVersionSupported ( fullySpecifiedDotnetVersion ) ) )
113- {
114- throw new Error ( `The distro ${ this . distro } does not officially support dotnet version ${ fullySpecifiedDotnetVersion } .` ) ;
115- }
116-
117- // Verify there are no conflicting installs
118- // Check existing installs ...
119- const supportStatus = await this . distroSDKProvider . getDotnetVersionSupportStatus ( fullySpecifiedDotnetVersion ) ;
120105 if ( supportStatus === DotnetDistroSupportStatus . Distro )
121106 {
122107 const microsoftFeedDir = await this . distroSDKProvider . getExpectedDotnetMicrosoftFeedInstallationDirectory ( ) ;
@@ -141,9 +126,10 @@ export class DotnetGlobalSDKLinuxInstallerResolver
141126 throw err ;
142127 }
143128 }
129+ }
144130
145- const existingInstall = await this . distroSDKProvider . getInstalledGlobalDotnetPathIfExists ( ) ;
146- // Check for a custom install
131+ private async VerifyNoCustomInstallExists ( supportStatus : DotnetDistroSupportStatus , fullySpecifiedDotnetVersion : string , existingInstall : string | null ) : void
132+ {
147133 if ( existingInstall && path . resolve ( existingInstall ) !== path . resolve ( supportStatus === DotnetDistroSupportStatus . Distro ? await this . distroSDKProvider . getExpectedDotnetDistroFeedInstallationDirectory ( ) : await this . distroSDKProvider . getExpectedDotnetMicrosoftFeedInstallationDirectory ( ) ) )
148134 {
149135 const err = new DotnetCustomLinuxInstallExistsError ( new Error ( `A custom dotnet installation exists at ${ existingInstall } .
@@ -153,8 +139,11 @@ export class DotnetGlobalSDKLinuxInstallerResolver
153139 this . acquisitionContext . eventStream . post ( err ) ;
154140 throw err ;
155141 }
156- // Check if we need to install or not, if we can install (if the version conflicts with an existing one), or if we can just update the existing install.
157- else if ( existingInstall )
142+ }
143+
144+ private async UpdateOrRejectIfVersionRequestDoesNotRequireInstall ( fullySpecifiedDotnetVersion : string , existingInstall : string | null )
145+ {
146+ if ( existingInstall )
158147 {
159148 const existingGlobalInstallSDKVersion = await this . distroSDKProvider . getInstalledGlobalDotnetVersionIfExists ( ) ;
160149 if ( existingGlobalInstallSDKVersion && Number ( VersionResolver . getMajorMinor ( existingGlobalInstallSDKVersion ) ) === Number ( VersionResolver . getMajorMinor ( fullySpecifiedDotnetVersion ) ) )
@@ -181,6 +170,27 @@ export class DotnetGlobalSDKLinuxInstallerResolver
181170 }
182171 // Additional logic to check the major.minor could be added here if we wanted to prevent installing lower major.minors if an existing install existed.
183172 }
173+ }
174+
175+ public async ValidateAndInstallSDK ( fullySpecifiedDotnetVersion : string ) : Promise < string >
176+ {
177+ // Verify the version of dotnet is supported
178+ if ( ! ( await this . distroSDKProvider . isDotnetVersionSupported ( fullySpecifiedDotnetVersion ) ) )
179+ {
180+ throw new Error ( `The distro ${ this . distro } does not officially support dotnet version ${ fullySpecifiedDotnetVersion } .` ) ;
181+ }
182+
183+ // Verify there are no conflicting installs
184+ // Check existing installs ...
185+ const supportStatus = await this . distroSDKProvider . getDotnetVersionSupportStatus ( fullySpecifiedDotnetVersion ) ;
186+ await this . VerifyNoConflictInstallTypeExists ( supportStatus , fullySpecifiedDotnetVersion ) ;
187+
188+ const existingInstall = await this . distroSDKProvider . getInstalledGlobalDotnetPathIfExists ( ) ;
189+ // Check for a custom install
190+ await this . VerifyNoCustomInstallExists ( supportStatus , fullySpecifiedDotnetVersion , existingInstall ) ;
191+
192+ // Check if we need to install or not, if we can install (if the version conflicts with an existing one), or if we can just update the existing install.
193+ await this . UpdateOrRejectIfVersionRequestDoesNotRequireInstall ( fullySpecifiedDotnetVersion , existingInstall ) ;
184194
185195 return await this . distroSDKProvider . installDotnet ( ) ? '0' : '1' ;
186196 }
0 commit comments