@@ -8,42 +8,46 @@ namespace Microsoft.DotNet.Workloads.Workload
8
8
{
9
9
static class WorkloadSetVersion
10
10
{
11
- public static string ToWorkloadSetPackageVersion ( string workloadSetVersion , out SdkFeatureBand sdkFeatureBand )
11
+ private static string [ ] SeparateCoreComponents ( string workloadSetVersion , out string [ ] sections )
12
+ {
13
+ sections = workloadSetVersion . Split ( [ '-' , '+' ] , 2 ) ;
14
+ return sections [ 0 ] . Split ( '.' ) ;
15
+ }
16
+
17
+ public static bool IsWorkloadSetPackageVersion ( string workloadSetVersion )
12
18
{
13
- string [ ] sections = workloadSetVersion . Split ( new char [ ] { '-' , '+' } , 2 ) ;
14
- string versionCore = sections [ 0 ] ;
15
- string ? preReleaseOrBuild = sections . Length > 1 ? sections [ 1 ] : null ;
19
+ int coreComponentsLength = SeparateCoreComponents ( workloadSetVersion , out _ ) . Length ;
20
+ return coreComponentsLength >= 3 && coreComponentsLength <= 4 ;
21
+ }
16
22
17
- string [ ] coreComponents = versionCore . Split ( '.' ) ;
23
+ public static string ToWorkloadSetPackageVersion ( string workloadSetVersion , out SdkFeatureBand sdkFeatureBand )
24
+ {
25
+ string [ ] coreComponents = SeparateCoreComponents ( workloadSetVersion , out string [ ] sections ) ;
18
26
string major = coreComponents [ 0 ] ;
19
27
string minor = coreComponents [ 1 ] ;
20
28
string patch = coreComponents [ 2 ] ;
21
-
22
29
string packageVersion = $ "{ major } .{ patch } .";
23
30
if ( coreComponents . Length == 3 )
24
31
{
25
32
// No workload set patch version
26
33
packageVersion += "0" ;
27
-
28
34
// Use preview specifier (if any) from workload set version as part of SDK feature band
29
35
sdkFeatureBand = new SdkFeatureBand ( workloadSetVersion ) ;
30
36
}
31
37
else
32
38
{
33
39
// Workload set version has workload patch version (ie 4 components)
34
40
packageVersion += coreComponents [ 3 ] ;
35
-
36
41
// Don't include any preview specifiers in SDK feature band
37
42
sdkFeatureBand = new SdkFeatureBand ( $ "{ major } .{ minor } .{ patch } ") ;
38
43
}
39
44
40
- if ( preReleaseOrBuild != null )
45
+ if ( sections . Length > 1 )
41
46
{
42
47
// Figure out if we split on a '-' or '+'
43
48
char separator = workloadSetVersion [ sections [ 0 ] . Length ] ;
44
- packageVersion += separator + preReleaseOrBuild ;
49
+ packageVersion += separator + sections [ 1 ] ;
45
50
}
46
-
47
51
return packageVersion ;
48
52
}
49
53
0 commit comments