Once you've installed, open a new command prompt and run the following command:
Once you've installed, open a new terminal and run the following command:
Command prompt
dotnet
If the command runs, printing out information about how to use dotnet, you're good to go.
Got an error?
If you receive a 'dotnet' is not recognized as an internal or external command error, make sure you opened a new command prompt. If you can't resolve the issue, use the I ran into an issue button to get help fixing the problem.
Create your app
In your command prompt, run the following commands:
In your terminal, run the following commands:
Command prompt
dotnet new console -lang F# -o myFSharpAppcd myFSharpApp
The dotnet command creates a new application of type console for you. The -lang parameter specifies the F# programming language and -o creates a directory named myFSharpApp where your app is stored, and populates it with the required files. The cd myFSharpApp command puts you into the newly created app directory.
The main file in the myFSharpApp folder is Program.fs. By default, it already contains the necessary code to write "Hello World from F#!" to the Console.
Program.fs
open System[<EntryPoint>]let main argv = printfn "Hello World from F#!" 0 // return an integer exit code
Run your app
In your command prompt, run the following command:
In your terminal, run the following command:
Command prompt
dotnet run
Congratulations, you've built and run your first F# app!
Write some code
Open Program.fs in any text editor, and replace all of the code with the following. If you want to, you can replace the name Ana with your name.
Program.fs
open System// Define a new function to print a name.// It is defined above the main function.let printGreeting name = printfn "Hello %s from F#!" name[<EntryPoint>]let main argv = // Call your new function! printGreeting "Ana" 0 // return an integer exit code
Save the Program.fs file, and run your code again.
Command prompt
dotnet run
Next steps
Now that you've got the basics, let's dig deeper into the language, with a tour of F#.