Skip to content

Instantly share code, notes, and snippets.

@cloudRoutine
Last active October 18, 2015 20:59
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloudRoutine/75fcf0651c740e07aa21 to your computer and use it in GitHub Desktop.
Save cloudRoutine/75fcf0651c740e07aa21 to your computer and use it in GitHub Desktop.
Build the Visual F# Compiler and Tools for .Net CoreCLR ( On Windows )

Make things easy for yourself and start by running posh as admin

If you already have dnvm installed remember to run update-self if you haven't recently

Clone and checkout the coreclr branch of Kevin Ransom's Fork of the Visual F# Compiler and Tools

Installing DNVM

You need DNVM as a starting point. DNVM enables you to acquire a (or multiple) .NET Execution Environment (DNX). DNVM is simply a script, which doesn't depend on .NET. You can install it via a PowerShell command. You can find alternate DNVM install instructions at the ASP.NET Home repo.

λ» @powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"

You must close your command-prompt and start a new one in order for the user-wide environment variables to take effect.

You can see the currently installed DNX versions with dnvm list, which will display an empty set of installed runtimes.

λ» dnvm list

Installing a .NET Core DNX

It's easy to install the latest .NET Core-based DNX, using the dnvm install command. The -u (or -Unstable) parameter installs latest unstable version.

λ» dnvm install -r coreclr latest -u

This will install the 32-bit version of .NET Core. If you want the 64-bit version, you can specify processor architecture:

λ» dnvm install -r coreclr -arch x64 latest -u

You can see the currently installed DNX versions with dnvm list (your display may vary as new versions of the DNX are published):

λ» dnvm list
Active Version           Runtime Architecture Location                       Alias
------ -------           ------- ------------ --------                       -----
       1.0.0-beta8-15736 coreclr x64          C:\Users\Jared\.dnx\runtimes
       1.0.0-beta8-15736 coreclr x86          C:\Users\Jared\.dnx\runtimes

You can choose which of these DNXs you want to use with dnvm use, with similar arguments.

λ» dnvm use -r coreclr -arch x64 1.0.0-beta8-15736

Adding C:\Users\Jared\.dnx\runtimes\dnx-coreclr-win-x64.1.0.0-beta8-15736\bin to process PATH

λ» dnvm list

Active Version           Runtime Architecture Location                       Alias
------ -------           ------- ------------ --------                       -----
  *    1.0.0-beta8-15736 coreclr x64          C:\Users\Jared\.dnx\runtimes
       1.0.0-beta8-15736 coreclr x86          C:\Users\Jared\.dnx\runtimes

Build FSharp for .NET Core

While in the directory you've cloned the visualfsharp repo to ( e.g. C:\Users\Jared\Github\fs-coreclr\visualfsharp ) fetch the DotNet buildtools using:

λ» .nuget\NuGet.exe restore packages.config -PackagesDirectory packages

If you have not added MSBuild to your PATH you add the dir

C:\Program Files (x86)\MSBuild\14.0\Bin

To build and pull in the corefx assemblies for nuget build coreclr using this command:

// For Debug
λ» msbuild src\fsharp\FSharp.Core\FSharp.Core.fsproj /p:TargetFramework=coreclr /t:Rebuild /p:RestorePackages=true 

// For Release
λ» msbuild src\fsharp\FSharp.Core\FSharp.Core.fsproj /p:TargetFramework=coreclr /t:Rebuild /p:RestorePackages=true  /p:Configuration=Release

otherwise build fsharp.core like this:

// For Debug
λ» msbuild src\fsharp\FSharp.Core\FSharp.Core.fsproj /p:TargetFramework=coreclr

// For Release
λ» msbuild src\fsharp\FSharp.Core\FSharp.Core.fsproj /p:TargetFramework=coreclr /p:Configuration=Release

then build the compiler with the command:

// For Debug
λ» msbuild src/fsharp-compiler-build.proj /p:TargetFramework=coreclr /t:Rebuild /p:RestorePackages=true

// For Release
λ» msbuild src/fsharp-compiler-build.proj /p:TargetFramework=coreclr /t:Rebuild /p:RestorePackages=true /p:Configuration=Release
@ctaggart
Copy link

FSharp.targets

@zpodlovics I got past the error with the FSharp.targets file with:

ln -s /opt/visualfsharp/lkg/FSharp-4.0.30319.1/bin/Microsoft.FSharp.targets /opt/visualfsharp/lkg/FSharp-4.0.30319.1/bin/Microsoft.FSharp.Targets

fssrgen.exe

The proto build also wants to run fssrgen.exe so:

nano /opt/visualfsharp/lkg/FSharp-4.0.30319.1/bin/fssrgen.exe
#!/bin/sh
mono /opt/visualfsharp/lkg/FSharp-4.0.30319.1/bin/FsSrGen.exe $@
chmod u+x /opt/visualfsharp/lkg/FSharp-4.0.30319.1/bin/fssrgen.exe

msbuild

I currently have msbuild setup like so:

mkdir /opt/bin
nano /opt/bin/msbuild
#!/bin/sh
mono /root/.dnx/packages/Microsoft.Build.Mono.Debug/14.1.0-prerelease/lib/MSBuild.exe $@   
chmod u+x /opt/bin/msbuild
export PATH=/opt/bin:$PATH

installing Mono

http://www.mono-project.com/docs/getting-started/install/linux/

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list
echo "deb http://download.mono-project.com/repo/debian wheezy-libjpeg62-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list
apt-get update
apt-get install -y mono-devel

If you end up having to troubleshoot missing libraries, then you toggle on/off some env vars.
http://www.mono-project.com/docs/advanced/runtime/logging-runtime-events/

export MONO_LOG_LEVEL="debug"
export MONO_LOG_MASK="asm,type"
unset MONO_LOG_LEVEL
unset MONO_LOG_MASK

@ctaggart
Copy link

I started a Dockerfile that we can use to troubleshoot.
https://hub.docker.com/r/ctaggart/visualfsharp/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment