Skip to content

Commit ad31c61

Browse files
authored
Skip experimental in recommending workloads (#45767)
We've had issues around (heuristically) finding the appropriate workloads to recommend that the user install if they're missing packs. This should help in that it will avoid recommending experimental workloads if there are any other options. I don't feel too attached to this PR.
1 parent fd19bf8 commit ad31c61

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadSuggestionFinder.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ private static T FindBest<T>(IEnumerable<T> values, params Comparison<T>[] compa
187187

188188
internal static WorkloadSuggestion GetBestSuggestion(ICollection<WorkloadSuggestion> suggestions) => FindBest(
189189
suggestions,
190+
(x, y) => ContainsExperimental(y.Workloads) - ContainsExperimental(x.Workloads),
190191
(x, y) => y.ExtraPacks - x.ExtraPacks,
191192
(x, y) => y.Workloads.Count - x.Workloads.Count);
192193

@@ -195,6 +196,8 @@ internal static WorkloadSuggestion GetBestSuggestion(ICollection<WorkloadSuggest
195196
/// </summary>
196197
public WorkloadSuggestion GetBestSuggestion() => GetBestSuggestion(UnsortedSuggestions);
197198

199+
private static int ContainsExperimental(HashSet<WorkloadId> set) => set.Any(w => w.ToString().Contains("experimental")) ? 1 : 0;
200+
198201
/// <summary>
199202
/// A partial or complete suggestion for workloads to install, annotated with which requested packs it does not satisfy
200203
/// </summary>

test/Microsoft.NET.Build.Tests/WorkloadTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public void Given_multi_target_It_should_get_suggested_workload_by_GetRequiredWo
315315
// Conditionally check the OS and modify the expected workloads on Linux
316316
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
317317
{
318-
expected = "android;wasi-experimental";
318+
expected = "android;wasm-tools";
319319
}
320320

321321
getValuesCommand.GetValues()

0 commit comments

Comments
 (0)