Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

make error for workload info clean Fixes #42581 #42630

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

Forgind
Copy link
Member

@Forgind Forgind commented Aug 9, 2024

Fixes #42581

dotnet workload list has a special check to ensure that if a global.json file exists that specifies a particular workload set, then that workload set is installed. If not, it informs the user that they should do that first.

dotnet workload --info did not. The result was that it would give an ugly error with a stack trace.

This gives it the clean error message.

The bug didn't mention this, but I believe dotnet --info is also broken in the same case. This resolves that as well.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Workloads untriaged Request triage from a team member labels Aug 9, 2024
@@ -51,9 +45,16 @@ internal static string GetWorkloadsVersion(WorkloadInfoHelper workloadInfoHelper
internal static void ShowWorkloadsInfo(ParseResult parseResult = null, WorkloadInfoHelper workloadInfoHelper = null, IReporter reporter = null, string dotnetDir = null, bool showVersion = true)
{
workloadInfoHelper ??= new WorkloadInfoHelper(parseResult != null ? parseResult.HasOption(SharedOptions.InteractiveOption) : false);
reporter ??= Utils.Reporter.Output;
var globalJsonInformation = workloadInfoHelper.ManifestProvider.GetGlobalJsonInformation();
if (globalJsonInformation?.WorkloadVersionInstalled == false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably don't need the == false,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

globalJsonInformation could be null, and if not, WorkloadVersionInstalled could be true or false, so this is really a bool?, hence the == false.

@marcpopMSFT marcpopMSFT merged commit a5fca69 into dotnet:main Aug 13, 2024
37 checks passed
@dsplaisted
Copy link
Member

/backport to release/9.0.1xx

Copy link
Contributor

Started backporting to release/9.0.1xx: https://github.com/dotnet/sdk/actions/runs/10950545869

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Area-Workloads untriaged Request triage from a team member
Projects
None yet
4 participants