Is it possible to use ASP.NET Core within an F# fsx script?

50 views Asked by At

Found that the question was pondered a few years ago: https://github.com/dotnet/fsharp/issues/8688

My code looks like

#r "nuget: Microsoft.NETCore.App"
#r "nuget: Microsoft.NETCore.App.Ref"
#r "nuget: Microsoft.AspNetCore"

open Microsoft.AspNetCore.Builder

let builder = WebApplication.CreateBuilder(args)

But that does not work.

1

There are 1 answers

0
Md Farid Uddin Kiron On

Is it possible to use ASP.NET Core within an F# fsx script?

No you can't do that, directly referencing ASP.NET Core within an F# fsx script isn't officially supported, but you can try that manually as a workarounds.

You would require to load assembly reference dll file then need to open it.

Let's say, you want to refer following dll file from your directory:

enter image description here

Use #r "path/to/assembly.dll" to reference assemblies manually.

Then you have to locate required ASP.NET Core assemblies in your .NET Core installation

For insctance: If I want to refer Microsoft.AspNetCore.dll from the above directory, then you can do as following:

#r "path/to/Microsoft.AspNetCore.App.8.0.0/Microsoft.AspNetCore.dll"

open Microsoft.AspNetCore

Note: I would highly recommend you to refer this official document