【问题标题】:How to make F# projects which will work same on VS2010 / VS2013-preview?如何制作在 VS2010 / VS2013-preview 上相同的 F# 项目?
【发布时间】:2013-07-05 17:52:12
【问题描述】:

新的 F# 项目自带

  <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 失败了,所以我什至无法根据这个项目文件编写构建脚本。

我的解决方案:

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

我设置了 v12.0 而不是 $(VisualStudioVersion),因为我的 msbuild 的 VisualStudioVersion 是 11。因此,但这会破坏与其他 Visual Studio 版本的兼容性。

我想我需要做一些类似的东西

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

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

但这甚至看起来都不是好的解决方案。有合适的方法吗?

我在运行 3.0 F# 编译器 fsc.exe 和类似软件 FAKE 时遇到问题:

无法加载文件或程序集 FSharp.Core、Version=4.3.0.0、Culture=neutral、PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一

那么如何不破坏 3.0 / msbuild 和 3.1 以及更新的 VS2013-preview 内容之间的兼容性?

【问题讨论】:

  • VS2013 项目是supposed to be backwards-compatible with VS2012,尽管 VS2012 项目确实需要一次性升级才能工作。如果您已将 VS2012 项目升级到 VS2013,并且之后无法使用 VS2012 构建它,则应报告该问题,以便为 VS2013 RTM 修复该问题。
  • VS2010呢?我没有 VS2012 来测试这个 &lt;Choose&gt; 是否在那里工作。
  • 我不知道。 VS2013 预览公告没有提到任何关于 VS2010 的内容,所以我认为这意味着您将无法(轻松)创建适用于所有 3 个版本的项目文件。

标签: visual-studio-2013 f# compatibility f#-3.1


【解决方案1】:

我猜丹尼应该给出的更具体的答案是:

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

这应该适用于所有版本。

【讨论】:

    【解决方案2】:

    我将从在两个版本中创建项目并区分项目文件开始。如果您构建的项目文件包含两个文件的超集,并具有适当的Condition 属性,以便每个版本的 VS 读取正确的部分,理论上它应该可以工作。

    【讨论】:

    • 我只是希望这个建议能奏效,但我现在无法确认,因为有些事情发生了变化,VS2013 已经发布,我没有 2012 安装,所以我什至不能自己代表这个问题.
    猜你喜欢
    • 1970-01-01
    • 2011-03-03
    • 2016-04-15
    • 2011-03-01
    • 1970-01-01
    • 2013-11-02
    • 1970-01-01
    • 2013-04-14
    • 1970-01-01
    相关资源
    最近更新 更多