如何制作能在VS2010/VS2013上运行的F#项目-预览版? [英] How to make F# projects which will work same on VS2010 / VS2013-preview?

查看:7
本文介绍了如何制作能在VS2010/VS2013上运行的F#项目-预览版?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的F#项目附带

  <Choose>
    <When Condition="'$(VisualStudioVersion)' == '11.0'">
      <PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)..Microsoft SDKsF#3.0Frameworkv4.0Microsoft.FSharp.Targets')">
        <FSharpTargetsPath>$(MSBuildExtensionsPath32)..Microsoft SDKsF#3.0Frameworkv4.0Microsoft.FSharp.Targets</FSharpTargetsPath>
      </PropertyGroup>
    </When>
    <Otherwise>
      <PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)MicrosoftVisualStudiov$(VisualStudioVersion)FSharpMicrosoft.FSharp.Targets')">
        <FSharpTargetsPath>$(MSBuildExtensionsPath32)MicrosoftVisualStudiov$(VisualStudioVersion)FSharpMicrosoft.FSharp.Targets</FSharpTargetsPath>
      </PropertyGroup>
    </Otherwise>
  </Choose>
  <Import Project="$(FSharpTargetsPath)" />

msbuild使用它失败,因此我甚至无法基于此项目文件编写生成脚本。

我的解决方案:

<Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudiov12.0FSharpMicrosoft.FSharp.Targets" />
我设置了v12.0而不是$(VisualStudioVersion),因为我的msbuild的VisualStudioVersion是11。因此,这会破坏与其他Visual Studio版本的兼容性。

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

<FSharpTargetsPath Condition="'$(VisualStudioVersion)' == '11.0'">$(MSBuildExtensionsPath32)..Microsoft SDKsF#3.0Frameworkv4.0Microsoft.FSharp.Targets</FSharpTargetsPath>

<FSharpTargetsPath Condition="'$(VisualStudioVersion)' == '12.0'">$(MSBuildExtensionsPath32)MicrosoftVisualStudiov12.0FSharpMicrosoft.FSharp.Targets</FSharpTargetsPath>

但这看起来甚至不是一个好的解决方案。有没有合适的办法?

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

无法加载文件或程序集FSharp.Core,版本=4.3.0.0,区域性=中性,PublicKeyToken=b03f5f7f11d50a3a‘或其依赖项之一

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

推荐答案

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

<PropertyGroup Condition="'$(FSharpTargetsPath)' == '' OR (!(Exists('$(FSharpTargetsPath)')))">
  <FSharpTargetsPath>$(MSBuildExtensionsPath32)..Common7IDECommonExtensionsMicrosoftFSharpToolsMicrosoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(FSharpTargetsPath)' == '' OR (!(Exists('$(FSharpTargetsPath)')))">
  <FSharpTargetsPath>$(MSBuildExtensionsPath32)MicrosoftVisualStudiov$(VisualStudioVersion)FSharpMicrosoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(FSharpTargetsPath)' == '' OR (!(Exists('$(FSharpTargetsPath)')))">
  <FSharpTargetsPath>$(MSBuildExtensionsPath32)..Microsoft SDKsF#4.0Frameworkv4.0Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(FSharpTargetsPath)' == '' OR (!(Exists('$(FSharpTargetsPath)')))">
  <FSharpTargetsPath>$(MSBuildExtensionsPath32)..Microsoft SDKsF#3.1Frameworkv4.0Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(FSharpTargetsPath)' == '' OR (!(Exists('$(FSharpTargetsPath)')))">
  <FSharpTargetsPath>$(MSBuildExtensionsPath32)..Microsoft SDKsF#3.0Frameworkv4.0Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<Import Project="$(FSharpTargetsPath)" />

这应该适用于所有版本。

这篇关于如何制作能在VS2010/VS2013上运行的F#项目-预览版?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆