Skip to content

Error when compiling on console #626

Open
@imetallica

Description

@imetallica

Description

I'm trying to compile my project via dotnet build, but it cannot load the System.Data.SqlClient assembly. Wierdly enough, it does compile on Visual Studio 2019 and Intellisense works as well.

Repro steps

  1. dotnet new console -lang F#

  2. dotnet add package SQLProvider

  3. Add this code:

module Foobar

open FSharp.Data.Sql

let [<Literal>] ConnString = "ValidConnString"

type private DB = SqlDataProvider<DatabaseVendor = Common.DatabaseProviderTypes.MSSQLSERVER,
                                                   ConnectionString = ConnString,
                                                   UseOptionTypes = true>

let private ctx = DB.GetDataContext()

And this is the .fsproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="src/Foobar.fs" />
    <Compile Include="src/Program.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="SQLProvider" Version="1.1.65" />
    <PackageReference Include="Suave" Version="2.5.5" />
    <PackageReference Include="System.Data.SqlClient" Version="4.6.1" />
  </ItemGroup>
</Project>
  1. dotnet build

Expected behavior

Load properly the assembly.

Actual behavior

# Roughly translation...

C:\Users\Iuri L. Machado\Documents\Projects\hub\EventLogger\src\Capturer\Ability.fs(8,19): error FS3033: The Type Provider 'FSharp.Data.Sql.SqlTypeProvider' related an error: Could not load file or assembly 'System.Data.SqlClient, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the given file. [C:\Users\Iuri L. Machado\Documents\Projects\hub\EventLogger\EventLogger.fsproj]

Known workarounds

I've tried the recommended workarounds, such as, copying the DLL to the given destination dir, but without success.

Related information

  • SQLServer
  • Happens on Windows/Linux/Mac
  • .NET Core 2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NET Core reference assembly loadingNot a bug, but a question about usability with .NET Core. Right dlls are not in ResolutionPath.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions