Skip to content

Commit 8e820df

Browse files
committed
Comments
1 parent 9840fbd commit 8e820df

File tree

7 files changed

+15
-16
lines changed

7 files changed

+15
-16
lines changed

src/Cli/dotnet/commands/dotnet-workload/restore/WorkloadRestoreCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public override int Execute()
5656
// If there's a workload set version specified in the global.json file, we need to make sure the workload set is installed before we try to discover workload ids.
5757
if (!string.IsNullOrWhiteSpace(workloadSetVersionFromGlobalJson))
5858
{
59-
if (creationResult.WorkloadResolver.GetWorkloadManifestProvider() is SdkDirectoryWorkloadManifestProvider provider && provider.WouldThrowException())
59+
if (creationResult.WorkloadResolver.GetWorkloadManifestProvider().WouldThrowException())
6060
{
6161
new WorkloadUpdateCommand(_result).Execute();
6262
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ public interface IWorkloadManifestProvider
1717
string? GetWorkloadVersion();
1818

1919
Dictionary<string, WorkloadSet> GetAvailableWorkloadSets();
20+
21+
bool WouldThrowException();
2022
}
2123
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@ public IEnumerable<string> GetManifestDirectories()
5555
public string GetSdkFeatureBand() => _sdkVersionBand;
5656
public string? GetWorkloadVersion() => _sdkVersionBand.ToString() + ".2";
5757
public Dictionary<string, WorkloadSet> GetAvailableWorkloadSets() => new();
58+
public bool WouldThrowException() => false;
5859
}
5960
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ public void RefreshWorkloadManifests() { }
779779
public IEnumerable<ReadableWorkloadManifest> GetManifests() => Enumerable.Empty<ReadableWorkloadManifest>();
780780
public string GetSdkFeatureBand() => _sdkFeatureBand;
781781
public string? GetWorkloadVersion() => _sdkFeatureBand.ToString() + ".2";
782+
public bool WouldThrowException() => false;
782783
}
783784
}
784785

test/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/FakeManifestProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public IEnumerable<ReadableWorkloadManifest> GetManifests()
4141
public string GetSdkFeatureBand() => "8.0.100";
4242
public Dictionary<string, WorkloadSet> GetAvailableWorkloadSets() => throw new NotImplementedException();
4343
public string? GetWorkloadVersion() => "8.0.100.2";
44+
public bool WouldThrowException() => false;
4445
}
4546

4647
internal class InMemoryFakeManifestProvider : IWorkloadManifestProvider, IEnumerable<(string id, string content)>
@@ -68,5 +69,6 @@ public IEnumerable<ReadableWorkloadManifest> GetManifests()
6869
public string GetSdkFeatureBand() => "8.0.100";
6970
public Dictionary<string, WorkloadSet> GetAvailableWorkloadSets() => throw new NotImplementedException();
7071
public string? GetWorkloadVersion() => "8.0.100.2";
72+
public bool WouldThrowException() => false;
7173
}
7274
}

test/dotnet-MsiInstallation.Tests/WorkloadSetTests.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -274,24 +274,16 @@ void SetupWorkloadSetInGlobalJson(out WorkloadSet originalRollback)
274274
AddNuGetSource(@"C:\SdkTesting\workloadsets", SdkTestingDirectory);
275275
}
276276

277-
[Fact]
278-
public void UpdateWorkloadSetViaGlobalJson()
279-
{
280-
SetupWorkloadSetInGlobalJson(out var originalRollback);
281-
282-
VM.CreateRunCommand("dotnet", "workload", "update").WithWorkingDirectory(SdkTestingDirectory).Execute().Should().Pass();
283-
GetRollback(SdkTestingDirectory).Should().NotBe(originalRollback);
284-
}
285-
286-
[Fact]
287-
public void InstallWorkloadSetViaGlobalJson()
277+
[Theory]
278+
[InlineData("restore")]
279+
[InlineData("update")]
280+
[InlineData("install")]
281+
public void UseGlobalJsonToSpecifyWorkloadSet(string command)
288282
{
289283
SetupWorkloadSetInGlobalJson(out var originalRollback);
290284

291-
VM.CreateRunCommand("dotnet", "workload", "install", "aspire")
292-
.WithWorkingDirectory(SdkTestingDirectory)
293-
.Execute().Should().Pass();
294-
285+
string[] args = command.Equals("install") ? ["dotnet", "workload", "install", "aspire"] : ["dotnet", "workload", command];
286+
VM.CreateRunCommand(args).WithWorkingDirectory(SdkTestingDirectory).Execute().Should().Pass();
295287
GetRollback(SdkTestingDirectory).Should().NotBe(originalRollback);
296288
}
297289

test/dotnet-workload-install.Tests/MockManifestProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ public IEnumerable<ReadableWorkloadManifest> GetManifests()
4949

5050
public string GetSdkFeatureBand() => SdkFeatureBand.ToString();
5151
public string GetWorkloadVersion() => SdkFeatureBand.ToString() + ".2";
52+
public bool WouldThrowException() => false;
5253
}
5354
}

0 commit comments

Comments
 (0)