7

New F# projects comes with

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

msbuild just fails with it so I even can't write an build script based on this project file.

My solution:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v12.0\FSharp\Microsoft.FSharp.Targets" />

I set v12.0 instead of $(VisualStudioVersion) because VisualStudioVersion is 11 for my msbuild. So but this breaks compatibility with other Visual Studio versions.

I guess I need to make something alike

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

and

<FSharpTargetsPath Condition="'$(VisualStudioVersion)' == '12.0'">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v12.0\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>

But that even doesn't look alike good solution. Is there proper way?

Also I have problems with running 3.0 F# compiler fsc.exe and software alike FAKE :

Could not load file or assembly FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies

So how to not break compatibility between 3.0 / msbuild and 3.1 and newer VS2013-preview stuff ?

ildjarn
  • 62,044
  • 9
  • 127
  • 211
cnd
  • 32,616
  • 62
  • 183
  • 313
  • 1
    VS2013 projects are [supposed to be backwards-compatible with VS2012](https://blogs.msdn.com/b/fsharpteam/archive/2013/06/27/announcing-a-pre-release-of-f-3-1-and-the-visual-f-tools-in-visual-studio-2013.aspx?Redirected=true), though VS2012 projects do require a one-time upgrade for this to work. If you've upgraded a VS2012 project to VS2013 and you're not able to build it with VS2012 afterwards, you should report the issue so it can be fixed for VS2013 RTM. – Jack P. Jul 08 '13 at 12:25
  • What about VS2010? I have no VS2012 to test if this `` works there. – cnd Jul 08 '13 at 12:43
  • I don't know. The VS2013 preview announcement didn't say anything about VS2010, so I'd take that to mean you won't (easily) be able to create project files that work across all 3 versions. – Jack P. Jul 08 '13 at 17:24

2 Answers2

2

The more specific answer that I guess Danny should have given is:

<PropertyGroup Condition="'$(FSharpTargetsPath)' == '' OR (!(Exists('$(FSharpTargetsPath)')))">
  <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(FSharpTargetsPath)' == '' OR (!(Exists('$(FSharpTargetsPath)')))">
  <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(FSharpTargetsPath)' == '' OR (!(Exists('$(FSharpTargetsPath)')))">
  <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(FSharpTargetsPath)' == '' OR (!(Exists('$(FSharpTargetsPath)')))">
  <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(FSharpTargetsPath)' == '' OR (!(Exists('$(FSharpTargetsPath)')))">
  <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<Import Project="$(FSharpTargetsPath)" />

This should work with all versions.

knocte
  • 16,941
  • 11
  • 79
  • 125
0

I would start by creating projects in both versions and diffing the project files. If you build a project file that contains the superset of both files, with appropriate Condition attributes so that each version of VS reads the correct parts, in theory it should work.

Guy Coder
  • 24,501
  • 8
  • 71
  • 136
Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275
  • I just hope this suggestion will work but I can't confirm it for now since some things changed, VS2013 is out and I have no 2012 install anymore so I even can't represent this issue by myself. – cnd Oct 27 '13 at 18:31