DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Coding
  3. Tools
  4. Create an F# Project in VSCode

Create an F# Project in VSCode

In this post we take a look at how to create an F# project using VSCode. (It's nice when an article does exactly what the title says it does, isn't it?)

Pedro Santos user avatar by
Pedro Santos
·
Jan. 31, 17 · Tutorial
Like (1)
Save
Tweet
Share
3.87K Views

Join the DZone community and get the full member experience.

Join For Free

Prerequisites

  • Operating system
    • Windows
    • MacOS
    • Linux
  • CLR
    • .Net Framework (Windows)
    • Mono (MacOs, Linux)
  • VSCode
    • With ionide extensions for VSCode (http://ionide.io/)
      • Ionide-FSharp
      • Ionide-FAKE
      • Ionide-Paket

Step-by-step Instructions

  • Create new directory
  • Move to new directory
  • At the console type Code . or open VSCode and then open the new directory you just created
  • Press [Shift] [Command/Ctrl] [P] and type F#
  • Select New Project
  • Choose classlib or console or other project type for the production project
  • Choose the project directory (if left empty, current directory will be used)
  • Provide a project name (using production.fsproj for this example)
  • Press [Shift] [Command/Ctrl] [P] and type FAKE
  • Choose Default build, you should see an output similar to this:
    Checking Paket version (downloading latest stable)...
    Paket.exe 3.33.5 is up to date.
    Paket version 3.33.5
    0 seconds - ready.
    Building project with version: LocalBuild Shortened DependencyGraph for Target Build: <== Build <== Clean ... 
  • Press [Shift][Command/Ctrl][P] and type F#
  • Select New Project
  • Choose fsunit for test code
  • Choose the project directory (if left empty current directory will be used)
  • Provide a project name (using test.fsproj for this example)
  • Open up the test.fsproj file
  • Press [Shift][Command/Ctrl][P] and type F#
  • Select Add Project Reference
  • Choose test.fsproj project as the project that you want to edit
  • Choose production.fsproj project as the reference you want to add
  • Verify that test.fsproj has been changed and contains a reference to production.fsproj
    ...
    <ItemGroup>
      <ProjectReference Include="../production/production.fsproj">
        <Name>production.fsproj</Name>
        <Project>{df896c20-dc7e-4d4d-90da-546d6154d641}</Project>
      </ProjectReference>
    </ItemGroup>
    ...

  • Press [Shift][Command/Ctrl][P] and type paket
  • Select Add Nuget Package
  • Type Nunit.Console
  • Verify that paket.dependencies gets updated with new dependency
    source https://www.nuget.org/api/v2
    nuget FAKE
    nuget FSharp.Core
    nuget FsUnit
    nuget FsCheck
    nuget nunit.console // <- !!!This line should be present!!!

  • Open build.fsx
  • Add open Fake.Testing after open Fake
    open Fake
    open Fake.Testing // <--!!!Add this line!!!

  • Add the test task
    let testAssemblies = !! (buildDir + "*Tests.dll") // <--!!!Add this line!!!
    Target "UnitTests" (fun _ -> testAssemblies |> NUnit3 id) // <--!!!Add this line!!!

  • Add UnitTests to the build
    "Clean"
    ==> "Build"
    ==> "UnitTests" // <--!!!Add this line!!!
    ==> "Deploy"
    RunTargetOrDefault "Build"

  • Press [Shift][Command/Ctrl][P] and type FAKE
  • Choose build
  • Choose UnitTests, you should see an output similar to this:
    Checking Paket version (downloading latest stable)...
    Paket.exe 3.33.5 is up to date.
    Paket version 3.33.5
    0 seconds - ready.
    Building project with version: LocalBuild Shortened DependencyGraph for Target UnitTests: <== UnitTests <== Build <== Clean ... 
    Voila!

Bonus

  • Press [Shift] [Command/Ctrl] [B]
  • Should show an error and you can choose to edit. Edit the configuration to run the build script
    {
      // See https://go.microsoft.com/fwlink/?LinkId=733558
      // for the documentation about the tasks.json format
      "version": "0.1.0",
      "command": "./build.sh", // <--!!!Modify this line to call your build script (build.sh on mac/linux) or (build.cmd on windows)!!!
      "isShellCommand": true,
      "args": [], // <--!!!Modify this line to remove arguments!!!
      "showOutput": "always"
    }

  • Press [Shift] [Command/Ctrl] [B], you should see an output similar to this:
    Checking Paket version (downloading latest stable)...
    Paket.exe 3.33.5 is up to date.
    Paket version 3.33.5
    0 seconds - ready.
    Building project with version: LocalBuild
    Shortened DependencyGraph for Target Build:
    <== Build
     <== Clean
    ...

This article was first published on the Codurance blog.

Visual Studio Code

Published at DZone with permission of Pedro Santos, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Kubernetes-Native Development With Quarkus and Eclipse JKube
  • A First Look at Neon
  • Best Navicat Alternative for Windows
  • [DZone Survey] Share Your Expertise and Take our 2023 Web, Mobile, and Low-Code Apps Survey

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: