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

Can't dotnet build apps with TypeProviders if installed the F# compiler with Visual Studio Build Tools #285

Closed MarneeDear closed 5 years ago

MarneeDear commented 5 years ago

Can't build apps with fsc.props if installed the F# compiler with Visual Studio Build Tools

I was getting this error building an app on TeamCity. The app uses FSharp.Configurationso to get it to build on .NET Core I added fsc.props.

[Target "CoreCompile"]      1>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.

[Target "CoreCompile"]      1>FSC : warning FS3005: Referenced assembly 'C:\Users\teamcity-service\.nuget\packages\fsharp.configuration\1.5.0\lib\net45\FSharp.Configuration.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found

I had installed the F# Compiler with the Visual Studio Build Tools installer instead of the IDE installer.

To get the build to work I added a PropertyGroup to fsc.props for the FscToolPath installed with the build tools installer.

<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>

I have a pull request coming shortly.

Repro steps

  1. Install F# compiler using the Visual Studio Build Tools installer, no IDE.

  2. Have a .NET Core application using a Type Provider like FSharp.Configuration

  3. Run a build using dotnet build

Expected behavior

It builds.

Actual behavior

See the dreaded

has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found

Related information