2015-05-03

importing FSharp.Targets, compatible with Visual Studio 2015 and Mono 4

MSBuild began shipping with Visual Studio 2013 a couple of years ago. The transition caused some turbulence with finding the Microsoft.FSharp.Targets file. With Visual Studio 2013 and 2015, this is how it is looked up because of the need to remain compatible with Visual Studio 2012 (version 11.0):


If you are targeting F# 3.1 and/or Visual Studio 2013 and above, you can make it much simpler:

Mono

The story for the cross platform builds on Mono was even worse with the introduction of $(VisualStudioVersion) in the path. Things got a bit ugly for a while, but it is much better now. The above line works on on the latest Mono releases which ship the F# Compiler for F# 3.1 (Open Source Edition). It works on Travis CI which has Mono 3.12.1. It works with Mono 4.0.0 too on my iMac. Without $(VisualStudioVersion) set, I was curious why it was working.  To figure it out I created a stripped down test.fsproj that prints some default properties:



The reason this works on Mono with $(VisualStudioVersion) not set is because Mono has a directory named v.


I created a pull request for FAKE with these changes and created this blog post to document it. I helped put several of the hacks in place during the turbulence and it feels like a good time to clean them up with Visual Studio 2015 and Mono 4 compatible with this much simpler approach.