From b136152ee1fb982d292b1246fe5f7bee209df12f Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Wed, 17 Apr 2024 09:12:57 -0400 Subject: [PATCH] fix: Handle unreadable global.json sdk version --- src/NvGet/Helpers/SolutionHelper.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NvGet/Helpers/SolutionHelper.cs b/src/NvGet/Helpers/SolutionHelper.cs index a3d3244..5c826b8 100644 --- a/src/NvGet/Helpers/SolutionHelper.cs +++ b/src/NvGet/Helpers/SolutionHelper.cs @@ -222,7 +222,8 @@ private static async Task GetGlobalJsonFileReferences(Cancel var references = globalJson ?.MSBuildSdks - ?.Select(s => new PackageIdentity(s.Key, new NuGetVersion(s.Value))) + ?.Select(s => NuGetVersion.TryParse(s.Value, out var version) ? new PackageIdentity(s.Key, version) : null) + ?.Where(v => v is not null) .ToArray() ?? Array.Empty(); return references