Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Workspace lib #32

Merged
merged 87 commits into from
Feb 4, 2019
Merged

add Workspace lib #32

merged 87 commits into from
Feb 4, 2019

Conversation

enricosada
Copy link
Collaborator

@enricosada enricosada commented Jan 26, 2019

ref #16

extract FSAC code for loading (fsproj and fsx) and package in a nice to use library (Dotnet.ProjInfo.Workspace), plus features and cleanup.

features:

  • notifications for loading/loaded/failed
  • same fsc info (fsc args etc)
  • traverse all projects (like f# -> c# -> f#)
  • allow configure msbuild (msbuild.exe or dotnet msbuild
  • api for fsx
  • cached projs by target framework
  • removed the helper target file in obj dir
  • easier way to test scenarios ( test/Dotnet.ProjInfo.Workspace.Tests )
  • support old fsproj (verbose) and .NET sdk fsproj (slim) both using Out Of Process msbuild (no msbuild libs as deps)
  • FCS helpers in optional lib Dotnet.ProjInfo.Workspace.FCS, to get data ready to be used in FCS

/cc @alfonsogarciacaro @Krzysztof-Cieslak @baronfel this mean we will remove the code for loading in the FSAC/fable and just do something like the following.
Mostly is also because is tons easier to improve and test

let loader = Dotnet.ProjInfo.Workspace.Loader()

loader.LoadProjects [ "./path/to/my.fsproj" ] // will traverse project references too

let parsed = loader.Projects // all projects info as `Map< (projPath * tfm),  ProjInfo >`

to get notifications

loader.Notifications.Add(fun (_, arg) ->
     printfn "%A" args // Arg is Loading/Loaded/Failed

to get FCS (todo, but likely)

let fcsHelper = new WorkspaceFcs()

fcsHelper.Bind(loader)

Other stuffs:

loader.LoadSln "./path/to/my.sln"  //load all sln
loader.MsbuildPath <- @"c:\my\msbuild.exe" // specify msbuild and dotnet msbuild to use

@alfonsogarciacaro
Copy link

Great to see you're improving he project @enricosada! 🙌 It'd be fantastic to be able to get the F# compiler args of a script. This is currently failing with current FCS package:

About the location of msbuild, Fable is only compatible with the new project format so we would just need to specify the dotnet executable location. Fable also needs this in a couple of other places (auto restore, spawning the dotnet process) but we cannot specify a path (Steffen wanted to do this) because dotnet-proj-info expects dotnet to be installed globally.

@enricosada
Copy link
Collaborator Author

enricosada commented Jan 28, 2019

hi @alfonsogarciacaro

Fable also needs this in a couple of other places (auto restore, spawning the dotnet process) but we cannot specify a path (Steffen wanted to do this) because dotnet-proj-info expects dotnet to be installed globally.

That's one of the reason of this splitted code, was easier to refactor (FSAC is too entangled).
This code already support specify custom msbuild and dotnet paths

let msbuildLocator = MSBuildLocator()
let config = // override msbuild/dotnet locations
  { LoaderConfig.Default(msbuildLocator) with
       MSBuildNetSdkHost = DotnetMsbuild("/path/to/dotnet") }
let loader = Loader.Create(config)

loader.LoadProjects [ @"/path/to/my.fsproj" ] // or loader.LoadSln("/path/to/my.sln")

loader.Projects // Map of (path: string) * ProjectOptions

It'd be fantastic to be able to get the F# compiler args of a script. This is currently failing with current FCS package:

I think it's working now ( Dotnet.ProjInfo.Workspace.FCS.Tests, test "can fsx"), but i'll add more tests, because there are little quirks (like what fsharp.core to use) who need to be parametrized or with better defaults.

let msbuildLocator = MSBuildLocator()
let netFwInfo = NetFWInfoConfig.Default(msbuildLocator) |> NetFWInfo.Create

let fcs = FSharpChecker.Create(..)

let fcsBinder = FCSBinder(netFwInfo, fcs)

let tfm = netFwInfo.LatestVersion () // or specify a .NET version like `"4.6.1"`

let projOptions =
      fcsBinder.GetProjectOptionsFromScriptBy(tfm, file, input)
      |> Async.RunSynchronously

@enricosada enricosada merged commit bb22431 into master Feb 4, 2019
@enricosada enricosada changed the title [WIP] add Workspace lib add Workspace lib Feb 4, 2019
@enricosada enricosada deleted the workspace branch February 10, 2019 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants