Share via


F# Project and Item Templates

Over the past few months I have posted up a few Project and Item Templates for F#. Here is a quick summary of those templates.

Windows Console Application

The template can be found on the Visual Studio Gallery:

https://visualstudiogallery.msdn.microsoft.com/031891a9-06c3-47db-9c7d-8c9d4a32546a

When the template is installed you get the following template added to your F# folder when creating a new F# project:

7510.image_17A196C0

The Project Template creates a Windows Console Application with the following components:

  • Program.fs: The application entry point defined
  • Arguments.fs: A simple command line parser placing all arguments into a dictionary
  • MyConsole.fs: A separate module for the custom console application code

Assembly Information File Item Template

The template can be found on the Visual Studio Gallery at:

https://visualstudiogallery.msdn.microsoft.com/06bc7a47-be14-42b9-a8cb-86031922ff83

This extension creates a file called AssemblyInfo.fs, that contains the standard assembly definitions usually associated with other programming languages.

Once this assembly information file is included in your project, you will be able to see the usual property definitions associated with the assembly:

assembly

Class Library Project Template

This template creates a Windows Library with a simple class definition. The template can be found on the Visual Studio Gallery:

https://visualstudiogallery.msdn.microsoft.com/a3f39bd9-9fd2-4465-a931-2163758a1447

When the template is installed you get the following template added to your F# folder when creating a new F# project:

class

This template also defines several Item Templates for creating the following project items:

  • F# Class – The definition of a simple F# class
  • F# Interface – The definition of a simple F# interface
  • F# Disposable Class – The definition of a F# class that implements IDisposable

Windows Service Project Template

This template that provides the elements for the creation windows service in F#. The template can be found on the Visual Studio Gallery:

https://visualstudiogallery.msdn.microsoft.com/1f2ee1da-e87f-4863-b98e-d8b7b63d2253

When the template is installed you get the following template added to your F# folder when creating a new F# project:

service

This template provides several projects elements:

  • A MyService.fs and Program.fs source file providing the service elements
  • An Installer.fs source file enabling the service to be installed using the installutil tool
  • A command file for installing and un-installing the service

The MyService.fs source file provides the implementation of the service. The template code provides the structure for the OnStart and OnStop methods and shows how an EventLog can be created and referenced:

WinForms Project Template

This template is for an F# WinForms application. This template can be found on the Visual Studio Gallery:

https://visualstudiogallery.msdn.microsoft.com/eba78049-a17e-4868-9ead-065da1421052

When the template is installed you get the following template added to your F# folder when creating a new F# project:

winforms

This template that defines two project elements:

  • MyForm.fs: This is a class, derived from Form, which the application will display. The template provides some TODO tags showing the user the locations for inserting form controls.
  • Main.fs: This controls the displaying of the form and ensures the STA Thread is used.

The MyForm.fs file provides the structure for a type derived from Form. It demonstrates the Form definition providing placeholders for adding forms to the control and hooking up both form and control events.