|
10 | 10 | using System.Linq;
|
11 | 11 | using System.Text.Json;
|
12 | 12 | using System.Text.Json.Serialization;
|
| 13 | +using System.Text.RegularExpressions; |
13 | 14 | using System.Xml.Linq;
|
14 | 15 | using Microsoft.Build.Framework;
|
15 | 16 | using Microsoft.Build.Utilities;
|
|
18 | 19 |
|
19 | 20 | namespace Microsoft.Workload.Build.Tasks
|
20 | 21 | {
|
21 |
| - public class InstallWorkloadFromArtifacts : Task |
| 22 | + public partial class InstallWorkloadFromArtifacts : Task |
22 | 23 | {
|
23 | 24 | [Required, NotNull]
|
24 | 25 | public ITaskItem[] WorkloadIds { get; set; } = Array.Empty<ITaskItem>();
|
@@ -48,6 +49,9 @@ public class InstallWorkloadFromArtifacts : Task
|
48 | 49 | private string _tempDir = string.Empty;
|
49 | 50 | private string _nugetCachePath = string.Empty;
|
50 | 51 |
|
| 52 | + [GeneratedRegex(@"^\d+\.\d+\.\d+(-[A-z]*\.*\d*)?")] |
| 53 | + private static partial Regex bandVersionRegex(); |
| 54 | + |
51 | 55 | public override bool Execute()
|
52 | 56 | {
|
53 | 57 | _tempDir = Path.Combine(Path.GetTempPath(), $"workload-{Path.GetRandomFileName()}");
|
@@ -292,8 +296,15 @@ private bool InstallWorkloadManifest(ITaskItem workloadId, string name, string v
|
292 | 296 | }
|
293 | 297 |
|
294 | 298 | string outputDir = FindSubDirIgnoringCase(manifestVersionBandDir, name);
|
| 299 | + var bandVersion = VersionBandForManifestPackages; |
| 300 | + // regex matching the version band, e.g. 6.0.100-preview.3.21202.5 => 6.0.100-preview.3 |
| 301 | + string packagePreleaseVersion = bandVersionRegex().Match(version).Groups[1].Value; |
| 302 | + string bandPreleaseVersion = bandVersionRegex().Match(bandVersion).Groups[1].Value; |
| 303 | + |
| 304 | + if (packagePreleaseVersion != bandPreleaseVersion && packagePreleaseVersion != "-dev" && packagePreleaseVersion != "-ci") |
| 305 | + bandVersion = bandVersion.Replace (bandPreleaseVersion, packagePreleaseVersion); |
295 | 306 |
|
296 |
| - PackageReference pkgRef = new(Name: $"{name}.Manifest-{VersionBandForManifestPackages}", |
| 307 | + PackageReference pkgRef = new(Name: $"{name}.Manifest-{bandVersion}", |
297 | 308 | Version: version,
|
298 | 309 | OutputDir: outputDir,
|
299 | 310 | relativeSourceDir: "data");
|
|
0 commit comments