ionide / proj-info

Parse and evaluate MsBuild project files
MIT License
64 stars 37 forks source link

getProjectInfo and loadProject don't seem to work now and aren't tested #122

Closed dsyme closed 2 years ago

dsyme commented 2 years ago

FSharp.Formatting picked up a dependency on getProjectInfo (which uses loadProject), but they no longer seem to work.

I note these don't have tests in this repo so we should add those

The error I was getting was:

  skipping project 'FSharp.Formatting.Markdown.fsproj' ... error - The SDK 'Microsoft.NET.Sdk' specified could not be found.  

I think because they don't know toolsPath. Anyway I replaced getProjectInfo by this snippet I found in the test suites

        let loadProject (path: string) =
                let cwd = System.IO.Path.GetDirectoryName path |> System.IO.DirectoryInfo
                let toolsPath = Ionide.ProjInfo.Init.init cwd None
                let tfm = ProjectLoader.getTfm path (dict extraMsbuildProperties)
                let readingProps =
                    Ionide.ProjInfo.ProjectLoader.getGlobalProps path tfm extraMsbuildProperties
                    |> Seq.toList
                    |> List.map (fun (KeyValue(k,v)) -> (k,v))
                let loader = WorkspaceLoader.Create(toolsPath, readingProps)
                loader.LoadProjects([ path ], customProperties, BinaryLogGeneration.Off) 

That seemed to improve things though I now get another error:


  skipping project 'FSharp.Formatting.Markdown.fsproj' because an error occurred while cracking it: System.Exception: error - System.ArgumentException: The input sequence was empty. (Parameter 'source')
   at Microsoft.FSharp.Collections.SeqModule.Head[T](IEnumerable`1 source) in D:\a\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 1364
   at Ionide.ProjInfo.SdkDiscovery.versionAt(DirectoryInfo cwd, FileInfo dotnetBinaryPath) in D:\a\proj-info\proj-info\src\Ionide.ProjInfo\Library.fs:line 106
   at Ionide.ProjInfo.Init.init(DirectoryInfo workingDirectory, FSharpOption`1 dotnetExe) in D:\a\proj-info\proj-info\src\Ionide.ProjInfo\Library.fs:line 182
   at fsdocs.Crack.parseProject@196(FSharpList`1 extraMsbuildProperties, FSharpList`1 customProperties, String path) in E:\GitHub\dsyme\FSharp.Formatting\src\fsdocs-tool\ProjectCracker.fs:line 199
log -
   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1439.Invoke(String message) in D:\a\_work\1\s\src\fsharp\FSharp.Core\printf.fs:line 1439
   at fsdocs.Crack.projectInfos@392.Invoke(String p) in E:\GitHub\dsyme\FSharp.Formatting\src\fsdocs-tool\ProjectCracker.fs:line 394```
baronfel commented 2 years ago

Closing this, as both mentioned functions are under test now for many different SDK bands in the test suite.

dsyme commented 2 years ago

Thank you!!!!