Bug 14922 - xBuild fails to parse F# 3.1 project files
Summary: xBuild fails to parse F# 3.1 project files
Status: RESOLVED FIXED
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-09-23 05:40 UTC by Gustavo Guerra
Modified: 2013-11-14 10:05 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Gustavo Guerra 2013-09-23 05:40:47 UTC
F# 3.0 projects files had an import like this:

<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')" />

but F# 3.1 project files have this instead:

<Choose>
  <When Condition="'$(VisualStudioVersion)' == '11.0'">
    <PropertyGroup>
      <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
    </PropertyGroup>
  </When>
  <Otherwise>
    <PropertyGroup>      <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
    </PropertyGroup>
  </Otherwise>
</Choose>

<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />

This is failing because $(FSharpTargetsPath) is not correctly replaced in the Import Project tag.
Comment 1 Mikayla Hutchinson [MSFT] 2013-09-23 18:31:25 UTC
So the targets depend on the VisualStudioVersion property having a value?
Comment 2 Gustavo Guerra 2013-09-23 18:37:23 UTC
If VisualStudioVersion doesn't have a value, the condition turns to '' == '11.0' so the Otherwise case is the valid one. So I was expecting FSharpTargetsPath to be set to $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets, but it's set to "" and InvalidProjectFileException is thrown in mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngineImport.cs, line 221
Comment 3 Gustavo Guerra 2013-09-25 16:55:05 UTC
This applies to a project upgraded from VS2012 to VS2013. For a F# project created directly in VS2013, there's more stuff that needs to be fixed :(
*ToolsVersion=12.0
*>= in Conditions
Comment 4 Gustavo Guerra 2013-09-25 17:35:29 UTC
VS2013 also includes a new ImportGroup tag that groups several Imports under a condition
Comment 5 Gustavo Guerra 2013-09-25 18:12:41 UTC
I've submitted a pull request with a fix: https://github.com/mono/mono/pull/767
Comment 6 Gustavo Guerra 2013-11-14 10:05:00 UTC
The pull request for this has been merged and according to @kumpera will be released in 3.2.5