Skip to content

Commit

Permalink
Fixed support for net core
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Czifro authored and Krzysztof-Cieslak committed Jan 25, 2017
1 parent cf02367 commit 992ff9a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,30 @@ type Commands (serialize : Serializer) =
project)

let (|NetCore|Net45|Unsupported|) file =
//.NET Core Sdk preview3 replace project.json with fsproj
//.NET Core Sdk preview3+ replace project.json with fsproj
//Easy way to detect new fsproj is to check the msbuild version of .fsproj
// MSBuild version 15 (`ToolsVersion="15.0"`) is the new project format
//The `dotnet-compile-fsc.rsp` are created also in `preview3`, so we can
//Post preview5 has (`Sdk="Fsharp.NET.Sdk;Microsoft.NET.Sdk"`), use that
// for checking .NET Core fsproj
//The `dotnet-compile-fsc.rsp` are created also in `preview3+`, so we can
// reuse the same behaviour of `preview2`
let rec findToolsVersion (sr:StreamReader) limit =
// only preview3+ uses ToolsVersion='15.0'
let isPreview3 (toolsVersion:string) = toolsVersion.Contains("=\"15.0\"")
let rec getProjectType (sr:StreamReader) limit =
// only preview3-5 uses ToolsVersion='15.0'
// post preview5 dropped this, check Sdk field
let isNetCore (line:string) = line.Contains("=\"15.0\"") || line.Contains("Fsharp.NET.Sdk")
if limit = 0 then
Unsupported // unsupported project type
else
let line = sr.ReadLine()
if not <| line.Contains("ToolsVersion") then
findToolsVersion sr (limit-1)
else // both net45 and preview3+ have 'ToolsVersion'
if isPreview3 line then NetCore else Net45
if not <| line.Contains("ToolsVersion") && not <| line.Contains("Sdk=") then
getProjectType sr (limit-1)
else // both net45 and preview3-5 have 'ToolsVersion', > 5 has 'Sdk'
if isNetCore line then NetCore else Net45
if not <| File.Exists(projectFileName) then Net45 // no such file is handled downstream
elif Path.GetExtension file = ".json" then NetCore // dotnet core preview 2 or earlier
else
use sr = File.OpenText(file)
findToolsVersion sr 3
getProjectType sr 3


return
Expand Down

0 comments on commit 992ff9a

Please sign in to comment.