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
564 stars 144 forks source link

Cannot build SqlServer Tests Project on Windows with .Net Core 2.2 #623

Open mackenzie-orange opened 5 years ago

mackenzie-orange commented 5 years ago

Description

Cannot build SqlProvider Core test project on Windows with .NetCore 2.2. Fails with error message:

FSC: error FS0226: The file extension of 'C:\Program Files\dotnet\sdk\2.2.300\FSharp\fsc.exe' is not recognized. Source files must have extension .fs, .fsi, .fsx, .fsscript, .ml or .mli.

Repro steps

  1. Install Visual studio 2019

  2. Open the SqlProvider.Core.Tests projecct and comment out any code that is related doing SqlProvider stuff in Program.fs.

  3. Update the SqlProvider.Core.Tests project to use Visual Studio 2019:

    <PropertyGroup Condition="'$(IsWindows)' == 'true'">
    <FscToolPath>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\FSharp</FscToolPath>
    <FscToolExe>fsc.exe</FscToolExe>
  4. Run \SQLProvider\tests\SqlProvider.Core.Tests\MsSql> dotnet build

Full output:

PS C:\..\SQLProvider\tests\SqlProvider.Core.Tests\MsSql> dotnet build
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 28.14 ms for C:\..\dev\SQLProvider\tests\SqlProvider.Core.Tests\MsSql\SqlProvider.Core.Tests.fsproj.
FSC : error FS0226: The file extension of 'C:\Program Files\dotnet\sdk\2.2.300\FSharp\fsc.exe' is not recognized. Source files must have extension .fs, .fsi, .fsx, .fsscript, .ml or .mli. [C:\..\SQLProvider\tests\SqlProvider.Core.Tests\MsSql\SqlProvider.Core.Tests.fsproj]

Build FAILED.

FSC : error FS0226: The file extension of 'C:\Program Files\dotnet\sdk\2.2.300\FSharp\fsc.exe' is not recognized. Source files must have extension .fs, .fsi, .fsx, .fsscript, .ml or .mli. [C:\..\SQLProvider\tests\SqlProvider.Core.Tests\MsSql\SqlProvider.Core.Tests.fsproj]
    0 Warning(s)
    1 Error(s)

Expected behavior

Expect this project to build successfully.

Related information

Full un-scrubbed build output with -verbosity:n: build_output.txt

Thorium commented 5 years ago

I haven't tried .NET Core 2.2, but works perfectly in my .NET Core 2.1. Sounds like it's trying to compile fsc.exe...

mackenzie-orange commented 5 years ago

@Thorium Do you have an example project that pulls on this together? I'm currently on the fence about using F# because of this problem. At the moment, I can't get anything with F# + SQL working.

mackenzie-orange commented 5 years ago

I tried going back to .net core 2.1 like you suggested. I also followed the setup exactly including the step 4 which I didn't notice before:

To roll back to 2.1, I had to run this command to switch my sdk: dotnet new globaljson --sdk-version 2.1.700

My fsproj file pointing to the F# in the visual studio directory, using latest sqlprovider version:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

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

  <ItemGroup>
    <PackageReference Include="SQLProvider" Version="1.1.65">
      <ExcludeAssets>compile</ExcludeAssets>
    </PackageReference>

    <PackageReference Include="System.Data.SqlClient" Version="4.6.1" />
  </ItemGroup>

  <PropertyGroup>
    <FscToolPath>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\FSharp</FscToolPath>
    <FscToolExe>fsc.exe</FscToolExe>
  </PropertyGroup>

  <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
    <Exec Command="xcopy %USERPROFILE%\.nuget\packages\SQLProvider\1.1.65\lib\net451\FSharp.Data.SqlProvider.dll compiletime\ /y" />
  </Target>

  <ItemGroup>
    <Reference Include="FSharp.Data.SqlProvider">
      <HintPath>compiletime/FSharp.Data.SqlProvider.dll</HintPath>
    </Reference>
  </ItemGroup>

  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="xcopy %USERPROFILE%\.nuget\packages\SQLProvider\1.1.65\lib\net451\FSharp.Data.SqlProvider.dll bin\Debug\netcoreapp2.1\ /y" />
  </Target>

</Project>

The F# program:

// Learn more about F# at http://fsharp.org

open System
open FSharp.Data.Sql

[<EntryPoint>]
let main argv =
    printfn "Hello World from F#!"
    0 // return an integer exit code

running dotnet build:

PS C:\...\test_sqlprovider> dotnet build
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 23.54 ms for C:\...\test_sqlprovider\test_sqlprovider.fsproj.
  C:\...\$HOME\.nuget\packages\SQLProvider\1.1.65\lib\net451\FSharp.Data.SqlProvider.dll
  1 File(s) copied
FSC : error FS0226: The file extension of 'C:\Program Files\dotnet\sdk\2.1.700\FSharp\fsc.exe' is not recognized. Source files must have extension .fs, .fsi, .fsx, .fsscript, .ml or .mli. [C:\...\test_sqlprovider\test_sqlprovider.fsproj]

Build FAILED.

FSC : error FS0226: The file extension of 'C:\Program Files\dotnet\sdk\2.1.700\FSharp\fsc.exe' is not recognized. Source files must have extension .fs, .fsi, .fsx, .fsscript, .ml or .mli. [C:\...\dev\test_sqlprovider\test_sqlprovider.fsproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.54

EDIT:

A coworker was able to reproduce the same error on his windows machine with this basic setup.

Thorium commented 5 years ago

Here are some samples: https://github.com/fsprojects/SQLProvider/tree/master/tests/SqlProvider.Core.Tests/ e.g. https://github.com/fsprojects/SQLProvider/tree/master/tests/SqlProvider.Core.Tests/MsSql

mackenzie-orange commented 5 years ago

yeah sorry, but I'm still having issues building this project. I initially reported the issue because I couldn't build the MsSql example.

This build output shows me cloning the repo, and running the build.cmd, it still fails: build_out.txt

It fails for an unrelated error to my original post. Sorry: I would really like to use this, but I've hit several roadblocks.

Thorium commented 5 years ago

I installed VS2019, and was able to build after a minor fix mentioned here: https://github.com/fsprojects/Paket/issues/2264#issuecomment-506368815 ...which is now in the master.

mackenzie-orange commented 5 years ago

That's great! How can I start using the new paket changes in my F# project?

Thorium commented 5 years ago

Just pull the latest version of SQLProvider and it should work...

mackenzie-orange commented 5 years ago

What should the "latest" version of SQLProvider be? I still see 1.1.65 on nuget.org.

Thorium commented 5 years ago

Sorry, before that, I did mean that the test projects of "build_output.txt" has now being fixed. Can you now get the MsSql test project to compile or not?

mackenzie-orange commented 5 years ago

Hmm still seeing an error when running build.cmd I've attached the new build output, and another file showing that I have fetched latest from git.

build_output.txt git_log.txt

what other information could I give you that would be helpful?