Published 4th of October, 2013, by Nikos Baxevanis. Tagged as f#.

How to configure MSBuild to locate the F# build targets


When the AutoFixture.AutoFoq build run on the CodeBetter CI server for the first time, the following error message appeared:

MSB4057: The target “Build” does not exist in the project.

That was strange since the build run successfully in a development workstation with VS 2012 and .NET 4.5 installed.

Solution (CI Server)

By moving the project to a different agent, with .NET 4.5 installed, the problem was solved on the CodeBetter CI server.

However, the same issue was reported again - this time in a development workstation with VS 2013 RC.

Solution (Workstation)

Adam Chester has provided a solution which seems to work pretty well for VS 2012, VS 2013, and the CodeBetter CI server.

The solution can be applied to all F# projects using the MSBuild platform.

The most important changes are shown below. You can also see the diff as an image here:


A note for VS 2012 users

While VS 2013 RC applies these changes automatically for F# projects, in VS 2012 the project file must be tweaked manually:

###Step 1 - Append:


###Step 2 - Find and Replace:

<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')" />


  <When Condition="'$(VisualStudioVersion)' == '11.0'">
      <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />

###Step 3 - Find and Replace:

<Reference Include='FSharp.Core, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'>


<Reference Include='FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'>

The F# build targets, compiler, and run time should be located successfully now.

Wish to comment?

You can comment on this post on GitHub. Alternatively, you can discuss this post on Twitter or elsewhere with a permalink. Ping me with the link, and I may respond.