Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/app/Fake.DotNet.Cli/DotNet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module DotNet =
open System.IO
open System.Security.Cryptography
open System.Text
open Newtonsoft.Json.Linq
open System.Text.Json

/// <summary>
/// .NET Core SDK default install directory (set to default SDK installer paths
Expand Down Expand Up @@ -64,12 +64,15 @@ module DotNet =
| Some globalJson ->
try
let content = File.ReadAllText globalJson.FullName
let json = JObject.Parse content
let sdk = json.Item("sdk") :?> JObject

match sdk.Property("version") with
| null -> None
| version -> Some(version.Value.ToString())
let json =
JsonDocument.Parse(content, JsonDocumentOptions(CommentHandling = JsonCommentHandling.Skip))

let sdk = json.RootElement.GetProperty("sdk")

match sdk.TryGetProperty("version") with
| false, _ -> None
| true, version -> Some(version.GetString())
with exn ->
failwithf "Could not parse `sdk.version` from global.json at '%s': %s" globalJson.FullName exn.Message

Expand Down
1 change: 0 additions & 1 deletion src/app/Fake.DotNet.Cli/paket.references
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ group fakemodule

FSharp.Core
NETStandard.Library
Newtonsoft.Json
// https://stackoverflow.com/questions/58326739/how-can-i-find-the-target-of-a-linux-symlink-in-c-sharp
Mono.Posix.NETStandard