Skip to content

getProjectInfo with relative path does not work. #185

@nojaf

Description

@nojaf

Describe the bug
Hello, in fsprojects/FSharp.Formatting#793 we discovered that ProjectLoader.getProjectInfo cannot be called with a relative project path.

Very concretely, it goes wrong in VisualTree.relativePathOf:

image

System.Uri doesn't accept the input:
(dotnet fsi)

> System.Uri(".\\src\\Fantomas.Core\\");;
System.UriFormatException: Invalid URI: The format of the URI could not be determined.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString)
   at <StartupCode$FSI_0002>.$FSI_0002.main@() in C:\Users\nojaf\Projects\stdin:line 1
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

To Reproduce

Changing the test project to:

[<EntryPoint>]
let main argv =
    Environment.CurrentDirectory <- @"C:\Users\nojaf\Projects\fantomas"
    
    let _toolsPath =
        Init.init (IO.DirectoryInfo(@"C:\Users\nojaf\Projects\fantomas")) (Some(IO.FileInfo(@"C:\Program Files\dotnet\dotnet.exe")))
        //Init.init (IO.DirectoryInfo Environment.CurrentDirectory) None

    let info = ProjectLoader.getProjectInfo @".\src\Fantomas.Core\Fantomas.Core.fsproj" [] BinaryLogGeneration.Off [
              "TargetPath"
              "OutputType"
              "IsTestProject"
              "IsPackable"
              "RepositoryUrl"
              "UsesMarkdownComments"
              "FsDocsCollectionNameLink"
              "FsDocsLogoSource"
              "FsDocsNavbarPosition"
              "FsDocsTheme"
              "FsDocsLogoLink"
              "FsDocsLicenseLink"
              "FsDocsReleaseNotesLink"
              "FsDocsSourceFolder"
              "FsDocsSourceRepository"
              "FsDocsWarnOnMissingDocs"
              "RepositoryType"
              "RepositoryBranch"
              "PackageProjectUrl"
              "Authors"
              "GenerateDocumentationFile"
              //Removed because this is typically a multi-line string and dotnet-proj-info can't handle this
              //"Description"
              "PackageLicenseExpression"
              "PackageTags"
              "Copyright"
              "PackageVersion"
              "PackageIconUrl"
              //Removed because this is typically a multi-line string and dotnet-proj-info can't handle this
              //"PackageReleaseNotes"
              "RepositoryCommit"
              "TargetFrameworks"
              "RunArguments" ]
    ignore info
    0

reproduces the problem after updating the global json (in Fantomas repository) to

{
  "sdk": {
    "version": "6.0.405"
  }
}

Oh and you probably need to build Fantomas.Core as well.

Expected behaviour

Either we should get an exception in ProjectLoader.getProjectInfo those relative paths are not supported, or this should work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions