fsprojects / FSharp.TypeProviders.SDK

The SDK for creating F# type providers
https://fsprojects.github.io/FSharp.TypeProviders.SDK/
MIT License
298 stars 94 forks source link

FSharp.TypeProviders.SDK nuget package usage is not simple and not documented #383

Closed AlexeyRaga closed 2 years ago

AlexeyRaga commented 2 years ago

Description

Env: .NET6, F# 6, MacOS, no packet

When creating a new provider and referencing FSharp.TypeProviders.SDK 7.0.3 from Nuget, getting the following compilation error:

  The type provider designer assembly 'AvroProvider.DesignTime.dll' could not be loaded from folder '/Users/alexey/src/test/AvroProvider/src/AvroProvider.DesignTime/bin/Debug/net6.0'. The exception reported was: System.IO.FileNotFoundException - Could not load file or assembly 'FSharp.TypeProviders.SDK, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

There is no place in the project that references FSharp.TypeProviders.SDK 1.0.0.0, however AvroProvider/src/AvroProvider.DesignTime/bin/Debug/net6.0/AvroProvider.DesignTime.deps.json includes this statement:

      "FSharp.TypeProviders.SDK/7.0.3": {
        "dependencies": {
          "FSharp.Core": "6.0.5"
        },
        "runtime": {
          "lib/netstandard2.1/FSharp.TypeProviders.SDK.dll": {
            "assemblyVersion": "1.0.0.0",
            "fileVersion": "1.0.0.0"
          }
        }
      }
    }

I am not sure if it is a cause of a symptom of the problem.

image

Repro steps

  1. Clone this project: https://github.com/AlexeyRaga/FSharp.AvroProvider

  2. do dotnet build (I am building it on MacOS)

Expected behavior

The provider builds and is accessible in the test project

Actual behavior

  The type provider designer assembly 'AvroProvider.DesignTime.dll' could not be loaded from folder '/Users/alexey/src/test/AvroProvider/src/AvroProvider.DesignTime/bin/Debug/net6.0'. The exception reported was: System.IO.FileNotFoundException - Could not load file or assembly 'FSharp.TypeProviders.SDK, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

Known workarounds

I wasn't able to find any

Related information

baronfel commented 2 years ago

That matches the version stamped on the DLL itself

image

but separately the version of that DLL should probably be fixed.

AlexeyRaga commented 2 years ago

Hmmm, you are right @baronfel! I haven't checked that assuming that the version is == to the package version and I now feel stupid :)

But if it is installed, do you have any idea of how to make it available?

I think (and it may again be an incorrect guess) that when the runtime package does

[<assembly:CompilerServices.TypeProviderAssembly("AvroProvider.DesignTime.dll")>]

it cannot see libraries that are installed with nuget. How do people normally workaround it?

dsyme commented 2 years ago

I took a look and noticed a few things

  1. The Runtime DLL should not reference the TPSDK https://github.com/AlexeyRaga/FSharp.AvroProvider/blob/52adec5c287e69fa129ce5f0c30643686a985c9b/src/AvroProvider.Runtime/AvroProvider.Runtime.fsproj#L16

  2. You need to make sure that the contents of the TPSDK end up in your package correctly

  3. A few other things were wwrong with the setup that the default template was providing

The fixes are here, they will also be in a PR to this repo https://github.com/AlexeyRaga/FSharp.AvroProvider/pull/1