fsprojects / SQLProvider

A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides.
https://fsprojects.github.io/SQLProvider
Other
570 stars 144 forks source link

Type provider assembly error on TypeProviderAssemblyAttribute and FSharp.Core (netcoreapp2.2 + paket) #637

Closed aggieben closed 4 years ago

aggieben commented 4 years ago

Description

I have failing builds as well as broken intellisense that appears to stem from the following issues:

The type provider 'C:\Users\ben\.nuget\packages\sqlprovider\1.1.66\lib\netstandard2.0\FSharp.Data.SqlProvider.dll' 
reported an error: Assembly attribute 'TypeProviderAssemblyAttribute' refers to a designer 
assembly 
'C:\Users\ben\.nuget\packages\sqlprovider\1.1.66\lib\netstandard2.0\FSharp.Data.SqlProvider.dll' 
which cannot be loaded or doesn't exist. Could not load file or assembly 
'FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one 
of its dependencies. The system cannot find the file specified. F# Compiler(3031)
Referenced assembly 'C:\Users\ben\.nuget\packages\sqlprovider\1.1.66\lib\netstandard2.0\FSharp.Data.SqlProvider.dll' 
has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' 
but no public type provider classes were found F# Compiler(3005)

Apologies for the odd formatting. Here's a screencap if that's easier: image

The part of this that has my scratching my head the most is why FSharp.Core fails to load.

I created this project using forge, but it's just using modified CLI templates for new projects. My .fsproj:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <DebugType>portable</DebugType>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="Db.fs" />
    <Compile Include="Program.fs" />
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>

And my paket.dependencies:

source https://api.nuget.org/v3/index.json

framework: >= netstandard2.0
nuget FSharp.Core
nuget Npgsql
nuget SQLProvider

group Build
source https://www.nuget.org/api/v2

nuget FAKE

The versions reported in paket.lock for these dependencies are: FSharp.Core: 4.7 Npgsql: 4.0.9 SQLProvider: 1.1.66

I'm using .NET Core 3.0 preview9:

C:\Users\ben\proj> dotnet --info
source https://api.nuget.org/v3/index.json

framework: >= netstandard2.0
nuget FSharp.Core
nuget Npgsql
nuget SQLProvider

group Build
source https://www.nuget.org/api/v2

nuget FAKE

Repro steps

Please provide the steps required to reproduce the problem

  1. Create new project with forge new, which creates empty projects with paket already configured

  2. add SQLProvider, Npgsql, and FSharp.Core to paket.dependencies

  3. paket install

  4. dotnet restore

  5. build or open in ionide-vs

Expected behavior

Type provider works, intellisense works

Actual behavior

Intellisense indicates build problems; dotnet build also indicates same top-level errrors

Known workarounds

Unsure. As best I understand it, recent SDKs (after 2.2?) supposedly don't require the .NET Core type provider workaround. (The issue https://github.com/dotnet/fsharp/issues/3303 is marked obsolete)

Related information

Thorium commented 4 years ago
  1. Check that have you specified FscToolPath in your fsproj-project file? If yes, that should point to a .NET Framework path of fsc.exe compliler , not to .NET Core path of fsc.exe

  2. Try upgrading more recent version of the SQLProvider

aggieben commented 4 years ago

@Thorium it appears that I no longer have this issue as of the latest release. Not sure what changed or when it changed. My issue is now https://github.com/fsprojects/SQLProvider/issues/645.