Skip to content

Package does not work with #r nuget (requires ResolutionFolder=__SOURCE_DIRECTORY__) #1340

@cartermp

Description

@cartermp

I think this package is doing some custom stuff, because it simply doesn't work with #r "nuget".

Firstly, Load simply does not work as advertised. Consider the following script:

#r "nuget: FSharp.Data"

open FSharp.Data

type Stocks = CsvProvider<"data/MSFT.csv">
let msft = Stocks.Load("data/MSFT.csv")

This fails at runtime because the location of data/MSFT.csv is assumed not to be relative to the script's location, but the location of the temporary project file where the package is restored:

System.IO.DirectoryNotFoundException: Could not find a part of the path '/var/folders/jt/zl19fbpd387_btngqwry6c5h0000gn/T/nuget/5312--c70c53f0-8e79-44c4-be8e-9157262e6715/data/MSFT.csv'

Secondly, it actually doesn't work even when you've loaded it. At design-time you will get correct names for columns, but at runtime it has no idea what they are:

#r "nuget: FSharp.Data"

open FSharp.Data

type Stocks = CsvProvider<"data/MSFT.csv">

let location = __SOURCE_DIRECTORY__ + "/data/MSFT.csv"
let msft = Stocks.Load(location)

let firstRow = msft.Rows |> Seq.head

firstRow.``Adj Close``

This fails with the following:

/Users/phillip/scratch/test.fsx(23,10): error FS0039: The type 'Row' does not define the field, constructor or member 'Adj Close'.

Third, GetSample does not work:

#r "nuget: FSharp.Data"

open FSharp.Data

type Stocks = CsvProvider<"data/MSFT.csv">
let msft = Stocks.GetSample()

msft.Rows |> Seq.head

In this case, it fails to find any rows at all, despite the data being passed as a static parameter to the provider.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions