F# 4.6 and Azure DevOps Build Setup

I have been doing a fair bit of Isomorphic F# with the team recently and keen to try out the Anonymous Record Type in F# 4.6. While everything worked well in a development environment after implementing anonymous records, the Azure DevOps continuous integration failed to compile. It was not able to recognize the new syntax.

At the time of writing, the FSharp.Compiler.Tools have not been updated with F# 4.6 support yet. As a result, embedding the compiler in the project is not an option.

In order to build F# 4.6 we need .NET Core 2.2. Luckily, Azure DevOps’ build definition is a YAML file and it is easy to change and source control. In this case, with a Microsoft hosted build agent. First make sure the build VM image is windows-2019. In the YAML file, setup the VM image like this:

pool:
  vmImage: 'windows-2019'

Then make sure the .NET Core version is 2.2. Simply add a task as the first step to use a specific version of .NET:

steps:
- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '2.2.x'

That’s it! This setup can be used to build F# 4.6 project on .NET Core 2.2.

References:

Leave a comment