Skip to content

Commit

Permalink
Dotnet 7 (#177)
Browse files Browse the repository at this point in the history
* Update projects to net 7.0

* Handle errors better in project graph

* Main fix for F# 7.0 CoreCompile

* Adds 7.0 to F# script TFM

* ProjectNodes in favor TopologicallySorted
  • Loading branch information
TheAngryByrd authored Nov 7, 2022
1 parent e523999 commit 5f29a09
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 58 deletions.
3 changes: 2 additions & 1 deletion src/Ionide.ProjInfo.FCS/Ionide.ProjInfo.FCS.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks Condition="'$(BuildNet7)' == 'true'">$(TargetFrameworks);net7.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion src/Ionide.ProjInfo.ProjectSystem/FSIRefs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,13 @@ let tfmForRuntime =
let netcore31 = Version(3, 1, 100, "")
let netcore5 = Version(5, 0, 100, "")
let netcore6 = Version(6, 0, 100, "")
let netcore7 = Version(7, 0, 100, "")

fun (sdkVersion: Version) ->

if netcore6 <= sdkVersion then
if netcore7 <= sdkVersion then
"net7.0"
else if netcore6 <= sdkVersion then
"net6.0"
else if netcore5 <= sdkVersion then
"net5.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks Condition="'$(BuildNet7)' == 'true'">$(TargetFrameworks);net7.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Ionide.ProjInfo.Tool/Ionide.ProjInfo.Tool.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks Condition="'$(BuildNet7)' == 'true'">$(TargetFrameworks);net7.0</TargetFrameworks>
<PackAsTool>true</PackAsTool>
<ToolCommandName>proj-info</ToolCommandName>
<RollForward>LatestMajor</RollForward>
Expand Down
1 change: 1 addition & 0 deletions src/Ionide.ProjInfo/Ionide.ProjInfo.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks Condition="'$(BuildNet7)' == 'true'">$(TargetFrameworks);net7.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Include="FsLibLog.fs" />
Expand Down
117 changes: 63 additions & 54 deletions src/Ionide.ProjInfo/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ module ProjectLoader =
[| "ResolveAssemblyReferencesDesignTime"
"ResolveProjectReferencesDesignTime"
"ResolvePackageDependenciesDesignTime"
// Populates ReferencePathWithRefAssemblies which CoreCompile requires.
// This can be removed one day when Microsoft.FSharp.Targets calls this.
"FindReferenceAssembliesForReferences"
"_GenerateCompileDependencyCache"
"_ComputeNonExistentFileProperty"
"CoreCompile" |]
Expand Down Expand Up @@ -756,18 +759,38 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri
<| fun () ->
let pg = ProjectGraph(path, ProjectCollection.GlobalProjectCollection, projectInstanceFactory)

pg.ProjectNodesTopologicallySorted
pg.ProjectNodes
|> Seq.distinctBy (fun p -> p.ProjectInstance.FullPath)
|> Seq.map (fun p -> p.ProjectInstance.FullPath)
|> Seq.iter (fun p -> loadingNotification.Trigger(WorkspaceProjectState.Loading p))

pg

let loadProjects (projects: ProjectGraph, customProperties: string list, binaryLogs: BinaryLogGeneration) =
let handleError (e: exn) =
let msg = e.Message
printfn "error -> %A" e
logger.error (Log.setMessage "Failed loading" >> Log.addExn e)

projects.ProjectNodes
|> Seq.distinctBy (fun p -> p.ProjectInstance.FullPath)
|> Seq.iter (fun p ->

let p = p.ProjectInstance.FullPath

if msg.Contains "The project file could not be loaded." then
loadingNotification.Trigger(WorkspaceProjectState.Failed(p, ProjectNotFound(p)))
elif msg.Contains "not restored" then
loadingNotification.Trigger(WorkspaceProjectState.Failed(p, ProjectNotRestored(p)))
else
loadingNotification.Trigger(WorkspaceProjectState.Failed(p, GenericError(p, msg))))

Seq.empty

try
lock WorkspaceLoaderViaProjectGraph.locker
<| fun () ->
let allKnown = projects.ProjectNodesTopologicallySorted |> Seq.distinctBy (fun p -> p.ProjectInstance.FullPath)
let allKnown = projects.ProjectNodes |> Seq.distinctBy (fun p -> p.ProjectInstance.FullPath)

let allKnownNames = allKnown |> Seq.map (fun p -> p.ProjectInstance.FullPath) |> Seq.toList

Expand All @@ -792,60 +815,46 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri

bm.EndBuild()

let buildProjs =
result.ResultsByNode.Keys
|> Seq.collect (fun (pgn: ProjectGraphNode) -> seq { yield pgn.ProjectInstance })
|> Seq.toList

logger.info (
Log.setMessage "{overallCode}, projects built {count} {projects} "
>> Log.addContextDestructured "count" (buildProjs |> Seq.length)
>> Log.addContextDestructured "overallCode" result.OverallResult
>> Log.addExn result.Exception
)

let projects =
buildProjs
|> Seq.map (fun p -> p.FullPath, ProjectLoader.getLoadedProjectInfo p.FullPath customProperties (ProjectLoader.LoadedProject p))

|> Seq.choose (fun (projectPath, projectOptionResult) ->
match projectOptionResult with
| Ok projectOptions ->

Some projectOptions
| Error e ->
logger.error (Log.setMessage "Failed loading projects {error}" >> Log.addContextDestructured "error" e)
loadingNotification.Trigger(WorkspaceProjectState.Failed(projectPath, GenericError(projectPath, e)))
None)

let allProjectOptions = projects |> Seq.toList

allProjectOptions
|> Seq.iter (fun po ->
logger.info (Log.setMessage "Project loaded {project}" >> Log.addContextDestructured "project" po.ProjectFileName)
loadingNotification.Trigger(WorkspaceProjectState.Loaded(po, allProjectOptions |> Seq.toList, false)))

allProjectOptions :> seq<_>
with
| e ->
let msg = e.Message

logger.error (Log.setMessage "Failed loading" >> Log.addExn e)

projects.ProjectNodesTopologicallySorted
|> Seq.distinctBy (fun p -> p.ProjectInstance.FullPath)
|> Seq.iter (fun p ->

let p = p.ProjectInstance.FullPath

if msg.Contains "The project file could not be loaded." then
loadingNotification.Trigger(WorkspaceProjectState.Failed(p, ProjectNotFound(p)))
elif msg.Contains "not restored" then
loadingNotification.Trigger(WorkspaceProjectState.Failed(p, ProjectNotRestored(p)))
if result.Exception |> isNull |> not then
handleError result.Exception
else
loadingNotification.Trigger(WorkspaceProjectState.Failed(p, GenericError(p, msg))))
let buildProjs =
result.ResultsByNode.Keys
|> Seq.collect (fun (pgn: ProjectGraphNode) -> seq { yield pgn.ProjectInstance })
|> Seq.toList

logger.info (
Log.setMessage "{overallCode}, projects built {count} {projects} "
>> Log.addContextDestructured "count" (buildProjs |> Seq.length)
>> Log.addContextDestructured "overallCode" result.OverallResult
>> Log.addExn result.Exception
)

let projects =
buildProjs
|> Seq.map (fun p -> p.FullPath, ProjectLoader.getLoadedProjectInfo p.FullPath customProperties (ProjectLoader.LoadedProject p))

|> Seq.choose (fun (projectPath, projectOptionResult) ->
match projectOptionResult with
| Ok projectOptions ->

Some projectOptions
| Error e ->
logger.error (Log.setMessage "Failed loading projects {error}" >> Log.addContextDestructured "error" e)
loadingNotification.Trigger(WorkspaceProjectState.Failed(projectPath, GenericError(projectPath, e)))
None)

let allProjectOptions = projects |> Seq.toList

allProjectOptions
|> Seq.iter (fun po ->
logger.info (Log.setMessage "Project loaded {project}" >> Log.addContextDestructured "project" po.ProjectFileName)
loadingNotification.Trigger(WorkspaceProjectState.Loaded(po, allProjectOptions |> Seq.toList, false)))

allProjectOptions :> seq<_>
with
| e -> handleError e

Seq.empty

interface IWorkspaceLoader with
override this.LoadProjects(projects: string list, customProperties, binaryLogs) =
Expand Down

0 comments on commit 5f29a09

Please sign in to comment.