-
Notifications
You must be signed in to change notification settings - Fork 25
FAQ
Some answers to frequently asked questions about developing for .NET Core. Some answers apply only to F#, others to all languages.
If something works with C#, it should work exactly the same for F#.
TABLE OF CONTENTS
- This is a FAQ, where are the real docs?
- .NET Core works with F#? Now? Without going crazy?
- Where to report bugs?
- How can i install it?
- I maintain an F# library published as nupkg and i want to support .NET Core
- Ok i want to start to convert a project?
- a new target framework?
- what dependencies version of libraries/tools?
- how can i check version resolved?
- some code need to be changed for .net core.. two version!
- Can i create a single nuget package with multiple framework versions inside (.NET 4.6, .NET Core)?
- But i already create the nuget package in my build, i dont want to use project.json for every framework
- i need to merge nupkg manually?
- But i already create the nuget package in my build, i dont want to use project.json for every framework
- Tools support?
- Travis/Appveyor
- Want to help?
The docs are really nice to read, and explain all scenarios.
So they are a good first read.
They're also open source, send a PR 😄
Yes, even during the beta, it was already okish with workarounds
With preview2
, .NET Core and F# work OOTB with project.json
Now with 1.0 rtm it run without issue OOTB, with intellisense and debugging in VSCode (with ionide)
If you see a bug, open an issue in:
- For F# compiler errors, crash - https://github.com/Microsoft/visualfsharp
- For .NET SDK (the cli) errors - https://github.com/dotnet/netcorecli-fsc/
- For .NET SDK if the same bug happens with similar C# code - https://github.com/dotnet/cli
- Not sure? - https://github.com/dotnet/netcorecli-fsc/
See the docs
- From http://dot.net choose .NET Core.
- That page shows the quickstart. For F#, just add
--lang f#
todotnet new
.
Or follow the (a bit hidden) Other downloads link for other os and types.
Both .NET Core and .NET SDK has two versions:
- from os native installers: like msi/pkg, install globally in the machine (see options)
-
from binaries: just a zip, download => unzip => add to
PATH
=> dotnet ready (multiple version can be installed in different directories). Zero fear about breaking the machine configuration. ❤️
The typical procedure is
- Create a new project (
lib
orconsole
) from template, doingdotnet new console -lang f#
- Copy to same directory of your .fsproj
- Restore all dependencies (
dotnet restore
) - Add all source files, same list as
Compile
inside.fsproj
- Add all additional nuget packages dependencies, like in
.fsproj
- Add all compiler directive
- Run
dotnet build
and fix any errors - Run
dotnet pack
to create your package
See docs, it's explained better
Usually, simplified (again read the docs)
Type | Name | TFM | Latest version as preview2 |
---|---|---|---|
library | .NET Standard | netstandard |
netstandard1.6 |
console app | .NET Core Application | netcoreapp |
netcoreapp1.0 |
TFM means target framework moniker, the short name ( ref nugets targetframeworks docs )
So, simplified:
- a library should target
netstandard1.6
- a console app should target
netcoreapp1.0
Is ok to use files generated by dotnet new console --lang f#
(or lib
instead of console
)
For Fsharp.Core
assembly, no GAC in .NET Core, use FSharp.Core
4.1.* nuget package
Do not use Microsoft.FSharp.Core.netcore
package, that's deprecated
After dotnet restore
open obj/project.assets.json
, search for package name.
Or do dotnet build -v n
to see compiler args, and references paths
If some code need to be changed, it's possible to maintain two versions of the same code under '#if` defines. When building, an upper case compiler define of TFM is passed to compiler.
so if
<TargetFramework>netstandard1.6</TargetFramework>
a compiler directive NETSTANDARD1_6
(the .
becomes _
) is passed to compiler
NOTE the compiler is F# 4.0, so it's possibile to use #if !DEF
, #if A || B
and #if A && B
like
#if NETSTANDARD1_6
let a = typeof<Program>.GetTypeInfo().Assembly.Name
#else
let a = typeof<Program>.GetType().Assembly.Name
#endif
Yes, nuget packages support multiple versions, and the .NET Core framework is like another target framework (like PCL, or .NET 4.5).
<TargetFrameworks>netstandard1.6;net462</TargetFrameworks>
But I already created the nuget package in my build, I don't want to use project.json for every framework
No need to go all in with new .fsproj
, with can have both in parallel, in same directory
You can use the .NET SDK cli tools (like dotnet pack
or dotnet build
) to build the assemblies (or the package)
and add these to your package
nuget pack
expects a nuspec and directory, so this works already. Also dotnet nuget
works
Or you can use a opensource third party tool (https://github.com/enricosada/dotnet-mergenupkg) to merge the already built packages.
NOTE BY AUTHOR the dotnet-mergenupkg
is an option written by me (@enricosada), so I like it and use it for some F# open source projects (suave/FCS/chessie). It tries to not change current build workflow, but uses dotnet cli to max. Feel free to ignore it.
- Build your package
A
normally - Create a package
B
with .NET Core (netstandard1.6
) usingdotnet pack
- Use
dotnet mergenupkg
to merge only assembly/nuspec fornetstandard1.6
fromB
toA
, soA
contains both.
See Status
- Visual Studio: NO, also 2017 doesn work yet
- Visual Studio Code: Yes build/run/intellisense/debug, with the Ionide plugin for F#.
- Notepad: from day 0
Both support .NET Core Sdk, but some changes are required in the config file to have the sdk already installed ootb (faster than download+install). See [https://docs.microsoft.com/en-us/dotnet/articles/core/tools/using-ci-with-cli] for more info
Awesome! See F# Core engineering group about .NET Core and SDK
- Home
- Status
- FAQ
- Info-for-library-maintainers
- Current Stable (LTS) Version:
- Next Version (WIP):
- Previous Versions: