Skip to content

Commit

Permalink
Merge pull request #15844 from tamasvajk/buildless/sdk-version-parsing
Browse files Browse the repository at this point in the history
C#: Improve `global.json` file parsing
  • Loading branch information
tamasvajk authored Mar 7, 2024
2 parents 92b086d + ea38bf5 commit 1fa151d
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 1fa151d

Please sign in to comment.