Skip to content

Commit

Permalink
C#: Improve global.json file parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasvajk committed Mar 7, 2024
1 parent 66d2a84 commit ea38bf5
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,16 @@ private static BuildScript DownloadDotNet(IBuildActions actions, ILogger logger,
try
{
var o = JObject.Parse(File.ReadAllText(path));
versions.Add((string)o?["sdk"]?["version"]!);
var v = (string?)o?["sdk"]?["version"];
if (v is not null)
{
versions.Add(v);
}
}
catch
{
// not a valid `global.json` file
logger.LogInfo($"Couldn't find .NET SDK version in '{path}'.");
continue;
}
}
Expand Down

0 comments on commit ea38bf5

Please sign in to comment.