Skip to content

Commit

Permalink
[tests] InstallWorkloadFromArtifacts: handle a stable band version (d…
Browse files Browse the repository at this point in the history
…otnet#102533)

If the sdk band version is like `8.0.100` (stable, no with no
preview/ci/dev suffixes), `bandPreleaseVersion`:

`string bandPreleaseVersion = bandVersionRegex().Match(bandVersion).Groups[1].Value;`

.. is `""` which breaks:

` bandVersion = bandVersion.Replace (bandPreleaseVersion, packagePreleaseVersion);`

```
System.ArgumentException: The value cannot be an empty string. (Parameter 'oldValue')
   at System.ArgumentException.ThrowNullOrEmptyException(String argument, String paramName)
   at System.String.Replace(String oldValue, String newValue)
   at Microsoft.Workload.Build.Tasks.InstallWorkloadFromArtifacts.InstallWorkloadManifest(ITaskItem workloadId, Strin
   at Microsoft.Workload.Build.Tasks.InstallWorkloadFromArtifacts.InstallAllManifests()
   at Microsoft.Workload.Build.Tasks.InstallWorkloadFromArtifacts.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingCo
```

This adds a null/empty string check on the local.
  • Loading branch information
radical committed May 22, 2024
1 parent 3e2b6eb commit b83186a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/tasks/WorkloadBuildTasks/InstallWorkloadFromArtifacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,13 @@ private bool InstallWorkloadManifest(ITaskItem workloadId, string name, string v
string packagePreleaseVersion = bandVersionRegex().Match(version).Groups[1].Value;
string bandPreleaseVersion = bandVersionRegex().Match(bandVersion).Groups[1].Value;

if (packagePreleaseVersion != bandPreleaseVersion && packagePreleaseVersion != "-dev" && packagePreleaseVersion != "-ci")
if (!string.IsNullOrEmpty(bandPreleaseVersion) &&
packagePreleaseVersion != bandPreleaseVersion &&
packagePreleaseVersion != "-dev" &&
packagePreleaseVersion != "-ci")
{
bandVersion = bandVersion.Replace (bandPreleaseVersion, packagePreleaseVersion);
}

PackageReference pkgRef = new(Name: $"{name}.Manifest-{bandVersion}",
Version: version,
Expand Down

0 comments on commit b83186a

Please sign in to comment.