dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.94k stars 788 forks source link

FSC : error FS0193: Could not find file 'c:\Users\kevinr\source\repos\Library2\Library2\tmpB4E3.dll #4795

Closed KevinRansom closed 6 years ago

KevinRansom commented 6 years ago

When building a library built using the FSharp.Data.TypeProvider sql type providers fails with:

c:\Users\kevinr\source\repos\Library2\Library2>msbuild Library2.fsproj /v:minimal
Microsoft (R) Build Engine version 15.7.172.38367 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

FSC : error FS0193: Could not find file 'c:\Users\kevinr\source\repos\Library2\Library2\tmpCED1.dll'. [c:\Users\kevinr\source\repos\Library2\Library2\Library2.fsproj]

c:\Users\kevinr\source\repos\Library2\Library2>

Repro:

1.     Create an F# desktop Library project.
2.     Reference FSharp.Data.TypeProviders nuget package
3.     Create a sql database and table
4.     In the library project add code similar to:
module Mylib

open FSharp.Data.TypeProviders

// The database connection string
let [<Literal>] CONN = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=MyLocalDatabase;Integrated Security=True"

// Connect to the database at compile-time
type SqlData1 = SqlDataConnection<CONN>

// Connect to the database at runtime
let ctxt = SqlData1.GetDataContext()

// Execute a query
let categories =
    query { for d in ctxt.MyTable1 do
            where (d.Column1 <> null)
            select (d.Column1, d.Column2, d.Column3, d.Column4 ) }

Example project file attached:  <you will need to point the connectionstring to point to a db on your sql server>
[Library2.zip](https://github.com/Microsoft/visualfsharp/files/1953711/Library2.zip)

When you build the project it fails with an error

cartermp commented 6 years ago

FYI @dsyme we got a report of a case where the recent type provider change broke the usage of FSharp.Data.TypeProviders for .NET Framework projects

abelbraaksma commented 6 years ago

Is this a bug against the nightly or a public release? The CsvProvider still works for me, but that's with the RTM.

cartermp commented 6 years ago

Note: FSharp.Data.TypeProviders <> FSharp.Data

CsvProvider should work, especially since FSharp.Data has been updated to use the new Type Provider mechanisms. But I don't think FDT has seen any such update.

dsyme commented 6 years ago

This is either a regression in the compiler or a problem with the FSharp.Data.TypeProviders TP.

(Note: existing TPs should continue to work as before when using the compiler running with .NET Framework)

KevinRansom commented 6 years ago

It is a regression it was caused by this PR: https://github.com/Microsoft/visualfsharp/pull/4629

@abelbraaksma it is in the VS2017.7 preview compiler,

sir-wilhelm commented 6 years ago

I ran into the same FSC build error in my F# projects that reference FSharp.Data.TypeProvider after updating VS to 15.7.0.

KevinRansom commented 6 years ago

@sir-wilhelm

Yes the fix didn't make it into VS2017.7., it arrived too late. It will be in VS2017.8.

Kevin

davidoptima commented 6 years ago

We use FSharp.Data.TypeProvider in a production project so after upgrading to 15.7 we cannot longer build and as it’s production we can’t use the preview compiler, so we are now having to downgrade to 15.6.7. Can this fix be put into the next minor bugfix release?

cartermp commented 6 years ago

@davidoptima we'll do what we can to get this into a servicing release for 15.7. No guarantee when that will be at this time, largely because the release just went out and other teams are also collecting information about what to service.

@dsyme do you know if the latest FCT package has @KevinRansom's fix? If so, then @davidoptima and others can use it in the interim.

fbehrens commented 6 years ago

I have downgraded to 15.6.7 as well. @cartermp How will I know (when|which version) this fix has landed in Visual Studio ?

cartermp commented 6 years ago

@fbehrens This should be in for 15.7.2, which is the next servicing update.

brettfo commented 6 years ago

As a follow up, I just merged the fix into the internal 15.7.2 branch. As to when that branch is finalized, built, and shipped, however, is way above my pay grade.

ceth-x86 commented 6 years ago

I have 15.8.0 Preview 1.1 installed with the same bug. Are this fix included in this release ? Downgrading to 15.6.7 fixes the problem.

cartermp commented 6 years ago

@demas this fix is in 15.7.2 only. Perhaps 15.8 Preview 2 will also have the fix, but we're not sure yet.

brettfo commented 6 years ago

15.8p2 should have this fix already in the pipeline.

torbonde commented 6 years ago

Will this fix be available in the most recent nightly build, due to #4922 ?

brettfo commented 6 years ago

@torbonde Yes, it should. If you're not seeing it let us know.

KevinRansom commented 6 years ago

@torbonde the nightly doesn't ship with a compiler, However, . I believe it made it into the 15.7 release of VS. And so the latest update of the RTM visual studio should have it already.

torbonde commented 6 years ago

@KevinRansom Ok, I thought that's what the PR I mentioned above changed, but maybe I have misunderstood. I had this issue with 15.7.1, which I suppose is the latest update so far.

@brettfo I tried the most recent nightly build, but wasn't actually able to load any F# projects (got an error on solution load), let alone build them. For now I'll downgrade to 15.6.7 and wait for the 15.7.2 update.

cartermp commented 6 years ago

@torbonde I think @KevinRansom may have mistyped - the fix is not in the latest RTM release. It will be available in VS 15.7.2.

Solution load errors are a concern. Do you recall any error or have logs handy?

torbonde commented 6 years ago

@cartermp Sure. I just installed the latest nightly build, to see if the error had magically been fixed. It hadn't.:)

I get the following error on solution load (copy/paste from activity log):

# Type Description GUID Hr Source Time (UTC)
1417   Begin package load [FSharpProjectPackage] {91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}   VisualStudio 2018/05/21 08:07:24.467
1418 ERROR LegacySitePackage failed for package [FSharpProjectPackage]Source: 'FSharp.ProjectSystem.FSharp' Description: Could not load file or assembly 'Microsoft.VisualStudio.LanguageServices, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.LanguageServices, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.VisualStudio.LanguageServices, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at Microsoft.VisualStudio.FSharp.ProjectSystem.FSharpProjectPackage.Initialize() at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. {91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C} 80070002 VisualStudio 2018/05/21 08:07:24.468
1419 ERROR SetSite failed for package FSharpProjectPackage {91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C} 80070002 VisualStudio 2018/05/21 08:07:24.470
1420 ERROR End package load [FSharpProjectPackage] {91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C} 80070002 VisualStudio 2018/05/21 08:07:24.472

The error below occurs when instantiating fsi:

# Type Description GUID Hr Source Time (UTC)
1517 ERROR Construction of frame content failed. Frame identifier: ST:0:0:{dee22b65-9761-4a26-8fb2-759b971d6dfc} Frame caption: F# Interactive Exception details: System.InvalidCastException: Specified cast is not valid. at Microsoft.VisualStudio.Shell.Interop.IVsShell5.LoadPackageWithContext(Guid& packageGuid, Int32 reason, Guid& context) at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.GetPackage() at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ConstructContent()     VisualStudio 2018/05/21 08:07:27.249

I hope this helps. Otherwise, please let me know what I can do. Also, if this should be a separate issue, I'll create one.

sir-wilhelm commented 6 years ago

Thanks for the updates, 157.2 resolved the issue for me.

fbehrens commented 6 years ago

updating to 15.7.2 resolves #4872 for me as well, thanks for all updates

orient-man commented 6 years ago

updating to 15.7.2 didn't solve this issue for me. Here is repro project with WCF TypeProvider: https://github.com/orient-man/WcfTypeProviderNotWorking