question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot compile .NETCoreApp,v6.0 by FSharpChecker.Compile

See original GitHub issue

Cannot compile .NETCoreApp,v6.0 by FSharpChecker.Compile

With the latest FSharp.Compiler.Service (41.0.6) and net6.0 I cannot compile any async code with --targetprofile:netcore.

If the solution to this problem exists then this issue is a question. I desperately look for an answer. Otherwise this issue is a bug report because it is not possible compile or use some typical F# code.

Please find attached a project that compiles two libraries Test1.dll and Test2.dll from Test1.fs and Test2.fs respectively. FCSCompile_221105_0559.zip

Just run

dotnet run

Test1 compiles fine and creates Test1.dll ~ .NETCoreApp,Version=v3.1 (according to ILSpy).

Test2 fails to compile:

The module/namespace 'System' from compilation unit 'netstandard' did not contain the namespace, module or type 'IAsyncDisposable'

Presumably it has to be compiled as .NETCoreApp,Version=v6.0 but it is not clear how.

F# compiler options do not have anything suitable (or I miss it).

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
vzarytovskiicommented, Nov 14, 2022

Update: with recent net7.0 and FSharp.Compiler.Service 42.7.101 the issue is the same.

As far as I understand, there is no known way to specify the TargetFramework. So some default is used. But why is the default .NETCoreApp,Version=v3.1 in the described scenario? Per https://dotnet.microsoft.com/en-us/platform/support/policy its support is coming to an end next month.

I can’t wrap my head around it quite yet, need to think about it a bit more.

1reaction
nightromancommented, Nov 7, 2022

@T-Gro This does not help. Namely if in the attached project and code I use @"-r:C:\...\bin\Debug\net6.0\FSharp.Core.dll" (see below) then the problem is the same. The explicitly referenced FSharp.Core.dll is correct, .NETStandard,Version=v2.1

// Test2: it fails to compile ~ The module/namespace 'System' from compilation unit 'netstandard' did not contain the namespace, module or type 'IAsyncDisposable'
// Presumably it has to be compiled as .NETCoreApp,Version=v6.0 but it is not clear how

let args2 = [|
    "fsc.exe"
    @"-r:C:\...\bin\Debug\net6.0\FSharp.Core.dll"
    "--targetprofile:netcore"
    "--target:library"
    $"-o:{root}/Test2.dll"
    $"{root}/Test2.fs"
|]

let res2 =
    checker.Compile args2
    |> Async.RunSynchronously
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to directly invoke F# compiler on .NET Core?
I know about dotnet build & co, but I don't want to involve them when I only need to compile a simple problem,...
Read more >
Unable to compile .net 6.0 projects in VS 2022
I am unable to compile .net 6.0 projects in VS 2022 (version 17.4.3). I see error message that - MSB3971 The reference assemblies...
Read more >
Compiler Options - F# | Microsoft Learn
Use F# compiler command-line options to control the compilation of your F# apps and libraries.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found