If you're on a Mac with an Apple M1 or M2 chip, you need to install the Arm64 version of the SDK.
Check everything installed correctly
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:
Terminal
dotnet --version
If the installation succeeded, you should see version 8.0.100 or higher outputted:
Command prompt
8.0.100
If everything looks good, select the Continue button below to go to the next step.
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 quickly restarting your machine doesn'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 command to create your app:
In your terminal, run the following command to create your app:
Terminal
dotnet new console -lang F# -o MyFSharpApp
Note: some terminals may require you to add quotes around F# like this: "F#".
Then, navigate to the new directory created by the previous command:
Terminal
cd 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
// For more information see https://aka.ms/fsharp-console-appsprintfn "Hello from F#"
Select the Continue button below to go to the next step.
Got an error?
If you receive a message similar to Template "Console Application" could not be created. Access to the path 'C:\Windows\System32\MyApp' is denied., change your current directory to one where you have permissions to create a new folder and try to run the command again.
If Windows can't find the SDK when you try to create the project and you are sure you have installed the SDK, your machine might have an issue with the PATH environment variable. See this Stack Overflow post for instructions on how to diagnose and fix this issue.
If you can't resolve the issue you're having, select the I ran into an issue button below to get help fixing the problem.
Run your app
In your command prompt, run the following command:
In your terminal, run the following command:
Terminal
dotnet run
If your app ran successfully, you should see the following output:
Command prompt
Hello from F#
Congratulations, you've built and run your first F# app! Select the Continue button below to go to the next step.
Edit your 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
// Define a new function to print a name.let printGreeting name = printfn $"Hello {name} from F#!"// Call your new function!printGreeting "Ana"
Save the Program.fs file and run your code again.
Terminal
dotnet run
If your app ran successfully, you should see an output similar to the following:
Command prompt
Hello Ana from F#!
Next steps
Now that you've got the basics, let's dig deeper into the language, with a self-guided learning of F#.