fsprojects / FSharp.Configuration

The FSharp.Configuration project contains type providers for the configuration of .NET projects.
http://fsprojects.github.io/FSharp.Configuration/
Other
114 stars 63 forks source link

"No public type provider classes found" error when using dotnet cli #145

Closed sircuri closed 5 years ago

sircuri commented 5 years ago

I'm trying to create an F# application using the YamlConfig type provider in the .NET Core 2.1 SDK.

The following error keeps popping up when building this solution using the dotnet CLI:

error FS3053 : The type provider 'FSharp.Configuration.ConfigTypeProvider+FSharpConfigurationProvider' reported an error : The type provider constructor has thrown an exception: Exception has been thrown by the target of an invocation. [/Staging.FSharp/DataVault.Staging.FSharp.fsproj]
FSC : warning FS3005: Referenced assembly '/root/.nuget/packages/fsharp.configuration/2.0.0-alpha2/lib/netstandard2.0/FSharp.Configuration.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found

A workaround on a windows machine is to use the MSBuild tool instead of the dotnet CLI. But building it on a Ubuntu machine with only .NET Core SDK installed is a different story. There is no MSBuild CLI.

I have tried to search for this issue, but I don't even understand where this issue is coming from. Is it the dotnet CLI, is it an YamlConfig type provider issue or something completely different? I'm not even sure if this is the right place to address this issue at all. Hope somebody can shed some light on this annoying compile error.

Thanks

sergey-tihon commented 5 years ago

Did you add fcs.props file to your project? https://github.com/Microsoft/visualfsharp/issues/3303

Sent from my iPhone

On Sep 12, 2018, at 00:06, Arjen notifications@github.com wrote:

I'm trying to create an F# application using the YamlConfig type provider in the .NET Core 2.1 SDK.

The following error keeps popping up when building this solution using the dotnet CLI:

error FS3053 : The type provider 'FSharp.Configuration.ConfigTypeProvider+FSharpConfigurationProvider' reported an error : The type provider constructor has thrown an exception: Exception has been thrown by the target of an invocation. [/Staging.FSharp/DataVault.Staging.FSharp.fsproj] FSC : warning FS3005: Referenced assembly '/root/.nuget/packages/fsharp.configuration/2.0.0-alpha2/lib/netstandard2.0/FSharp.Configuration.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found A workaround on a windows machine is to use the MSBuild tool instead of the dotnet CLI. But building it on a Ubuntu machine with only .NET Core SDK installed is a different story. There is no MSBuild CLI.

I have tried to search for this issue, but I don't even understand where this issue is coming from. Is it the dotnet CLI, is it an YamlConfig type provider issue or something completely different? I'm not even sure if this is the right place to address this issue at all. Hope somebody can shed some light on this annoying compile error.

Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

sircuri commented 5 years ago

@sergey-tihon Thank you for pointing that out. I had no idea what to search for, but this is indeed the issue I have!

MarneeDear commented 5 years ago

Adding the fsc.props file will work, but the one linked above might not work for your environment. If you are running on a build server you probably installed the F# compiler and dotnet build tools using the Visual Studio Build Tools installer instead of a Visual Studio IDE installer. In that case you can add this PropertyGroup (check your VIsual Studio install for your environment's path)

<PropertyGroup Condition="'$(IsWindows)' == 'true' AND Exists('C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsc.exe')">
    <FscToolPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\FSharp</FscToolPath>
    <FscToolExe>fsc.exe</FscToolExe>
  </PropertyGroup>

This adds a check for the path to the FSC in the Visual Studio 2017 Build Tools.

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\FSharp