Skip to content

Commit

Permalink
Fixed NullReferenceException on missing version in global.json
Browse files Browse the repository at this point in the history
  • Loading branch information
xperiandri committed Sep 23, 2023
1 parent 13e3033 commit 730eacc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/Fake.DotNet.Cli/DotNet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ module DotNet =
let content = File.ReadAllText globalJson.FullName
let json = JObject.Parse content
let sdk = json.Item("sdk") :?> JObject
let version = sdk.Property("version").Value.ToString()
Some version
match sdk.Property("version") with
| null -> None
| version ->
let versionValue = version.Value.ToString()
let _ = Version.Parse (versionValue)
Some versionValue
with exn ->
failwithf "Could not parse `sdk.version` from global.json at '%s': %s" globalJson.FullName exn.Message

Expand Down

0 comments on commit 730eacc

Please sign in to comment.