Using Visual Studio to Write F# Programs
The Visual Studio Integrated Development Environment (IDE) includes support for F#, including code editing, IntelliSense, debugging, and features that assist in packaging and deploying applications. Visual F# supports many of the features supported in other .NET Framework languages.
There are two basic styles of development that Visual F# supports: scripts and projects. You can use an F# script when you just want to run a small amount of code that you do not want to make into a permanent application. You use a project when you are creating a more permanent application.
To create and run an F# script, you do not need to create a project. To create an F# script, on the File menu, point to New and then click File. In the New File dialog box, select Script in the Installed Templates list, and then select F# Script File. Scripts are designed for execution with F# Interactive (fsi.exe). For more information, see F# Interactive (fsi.exe) Reference.
Projects include a collection of files that produce a single assembly. Projects are designed for compilation with fsc.exe and can be run in the Visual Studio debugger. The assembly that is produced can be an executable file or a library (DLL). A project consists of source files all written in the same programming language. A solution is a collection of projects. Projects in a solution can be written in different languages. For example, you can have a Visual Basic or C# user interface for your application, which is one project, and an F# library as another project. One of these projects will be the startup project: the one that is set to run when you start the application.
To create an F# project, on the File menu, point to New and then click Project. In the New Project dialog box, select a project template. Visual Studio provides templates that enable you to create projects that already have all the basic elements and settings that support applications and libraries. In F#, you use the F# Library project template when you are creating a DLL and the F# Application project when you are creating an executable file. You can also target Silverlight by using the Silverlight project template.
When you deploy your applications to run on computers other than your development computer, you need to add a Setup or Deployment project to your solution, and configure it to include the F# runtime in the deployment. This scenario is fully described in Walkthrough: Using Visual F# to Create, Debug, and Deploy an Application.
Other languages support visual designers that enable you to create UIs for applications. F# programs can directly target the .NET Framework libraries, such as WPF, Windows Forms, or ASP.NET, that enable you to create UIs for applications in F#, but Visual Studio 2010 does not provide a visual designer to help you create interfaces. A typical scenario is to create a multiple-language solution with one Visual Basic or C# application project that contains the UI, and also have one or more F# library projects.
The order of files is significant in F# projects. Files in an F# project are processed in order by the F# compiler. The F# compiler requires that you define all constructs before you start to use them; therefore, the files that include the definition of any F# construct must appear earlier in the list of files in the project than the files that use that construct. You also must avoid circular dependencies that span multiple files. To make it easier to move files around in a project, F# provides commands that enable you to move files up or down in the file list in Solution Explorer. You can access these commands by right-clicking the files in the file list or using the keyboard shortcuts, which are displayed on the menu.
The following table summarizes some the file types that you can use in F# projects.
File type and extension
Implementation file (.fs)
Used for F# code.
Signature file (.fsi)
Used to specify the public signatures of modules and types in an F# implementation file. For more information, see Signatures (F#).
Used to include informal testing code in F# without adding the test code to your application, and without creating a separate project for it. By default, script files are not included in the build of a project even when they are part of a project.
Lists Visual Studio features and indicates which are supported in Visual F#.
Provides information about project settings in Visual F#.
Provides links to topics that describe Visual Studio dialog boxes that pertain to projects. F# project support is a subset of the Visual Studio support.
Introduces Visual F# and provides links to relevant topics.
Provides step-by-step instructions for developing applications in Visual F#.
Provides information about debugging in F#.
Provides links to introductory information about Visual F#.
Provides links to introductory tutorials for some aspects of programming in F#