2

I'm trying to build simple F# console program, using FAKE build tool which include MSBuild tool, but I got the following:

FSProject.fsproj: error : Target named 'Build' not found in the project.

How can I resolve this?

I'm using VS2013 and .NET 4.5

10
  • Show us the contents of the fsproj file. It seems likely you are missing an Import or the required target file. Does C:\Program Files (x86)\Microsoft F#\v4.0\Microsoft.FSharp.targets exist? Commented Oct 23, 2013 at 6:37
  • @mikez: if i undestood, VS does not include such targets by default. So should i manually edit *.fproj files for MSBuild? Also, i'm interesting in FAKE build tool (MSBuild is part of it). Commented Oct 23, 2013 at 7:21
  • You should not have to edit the fsproj file to build if you used the basic project that comes with VS and are building with MSBuild or VS. "Build" is not a target that exists by default. It is defined in the Microsoft.Common.targets file which is imported by the Microsoft.FSharp.targets file. Commented Oct 23, 2013 at 7:33
  • 1
    the problem was caused by the fact that I used MSBuild tool from c:\Windows\Microsoft.NET\Framework\v4.0.30319, but VS2013 actually packed with new MSBuild v12.0 [ProgramFilesX86]\MSBuild\12.0\bin. Commented Oct 23, 2013 at 20:26
  • 1
    and if anyone use FAKE build tool, y can fix MSBuild path according to github.com/fsharp/FAKE/blob/develop/src/app/FAKE/app.config#L4 Commented Oct 23, 2013 at 20:29

2 Answers 2

3

The problem was caused by the fact that FAKE build tool I used, uses older MSBuild tool version from c:\Windows\Microsoft.NET\Framework\v4.0.30319. But VS2013 F# projects can be builded only with new version of MSBuild installed in [ProgramFilesX86]\MSBuild\12.0\bin.

So, how to fix this issue in FAKE tool:

You should change FAKE.exe.config according to this

i.e. change MSBuildPath setting to actual path.

Sign up to request clarification or add additional context in comments.

1 Comment

Actually this should be fixed in the current develop branch.
0

To found the issue, you can created your own Build-target to the fsproj-file first:

<Target Name="Build"> <Message Text="Ext = $(MSBuildExtensionsPath)" /> <Message Text="Tools = $(MSBuildToolsVersion)" /> <Message Text="msb32 = $(MSBuildExtensionsPath32)" /> <Message Text="targ = $(TargetFrameworkIdentifier)" /> <Message Text="fs = $(FSharpTargetsPath)" /> <Message Text="vs = $(VisualStudioVersion)" /> </Target> 

The issue is probably that there is a condition saying something like

 <PropertyGroup Condition="'$(VisualStudioVersion)' != '11.0'"> <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup> 

but with recent Visual Studio the condition is not met or the path is actually somewhere else, like in VisualStudio\v$(MSBuildToolsVersion)\FSharp\ and not in VisualStudio\v$(VisualStudioVersion)\FSharp\ so as a quick fix you can fallback it to something else like

 <PropertyGroup Condition="'$(VisualStudioVersion)' != '11.0' And Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\')"> <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup> <PropertyGroup Condition="'$(VisualStudioVersion)' != '11.0' And Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(MSBuildToolsVersion)\FSharp\')"> <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(MSBuildToolsVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.