visual-studio-2013 - 如何制作在 VS2010/VS2013-preview 上同样工作的 F# 项目?

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

新的 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 :

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



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

最佳答案

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

  <Choose>
    <When Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#')">
      <PropertyGroup>
        <FSharpSdkPathPrefix>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#</FSharpSdkPathPrefix>
      </PropertyGroup>
    </When>
    <Otherwise>
      <Choose>
        <When Condition="Exists('$(MSBuildExtensionsPath32)\..\..\..\..\Microsoft SDKs\F#')">
          <PropertyGroup>
            <FSharpSdkPathPrefix>$(MSBuildExtensionsPath32)\..\..\..\..\Microsoft SDKs\F#</FSharpSdkPathPrefix>
          </PropertyGroup>
        </When>
        <Otherwise>
          <PropertyGroup>
            <FSharpSdkPathPrefix></FSharpSdkPathPrefix>
          </PropertyGroup>
        </Otherwise>
      </Choose>
    </Otherwise>
  </Choose>
  <PropertyGroup>
    <FSharpSdkPathSuffix>Framework\v4.0\Microsoft.FSharp.Targets</FSharpSdkPathSuffix>
  </PropertyGroup>
  <Choose>
    <When Condition="'$(FSharpSdkPathPrefix)' == ''">
      <PropertyGroup>
        <FSharpTargetsPath></FSharpTargetsPath>
      </PropertyGroup>
    </When>
    <Otherwise>
      <Choose>
        <When Condition="Exists('$(FSharpSdkPathPrefix)\4.0\$(FSharpSdkPathSuffix)')">
          <PropertyGroup>
            <FSharpTargetsPath>$(FSharpSdkPathPrefix)\4.0\$(FSharpSdkPathSuffix)</FSharpTargetsPath>
          </PropertyGroup>
        </When>
        <Otherwise>
          <Choose>
            <When Condition="Exists('$(FSharpSdkPathPrefix)\3.1\$(FSharpSdkPathSuffix)')">
              <PropertyGroup>
                <FSharpTargetsPath>$(FSharpSdkPathPrefix)\3.1\$(FSharpSdkPathSuffix)</FSharpTargetsPath>
              </PropertyGroup>
            </When>
            <Otherwise>
              <Choose>
                <When Condition="Exists('$(FSharpSdkPathPrefix)\3.0\$(FSharpSdkPathSuffix)')">
                  <PropertyGroup>
                    <FSharpTargetsPath>$(FSharpSdkPathPrefix)\3.0\$(FSharpSdkPathSuffix)</FSharpTargetsPath>
                  </PropertyGroup>
                </When>
                <Otherwise>
                  <PropertyGroup>
                    <FSharpTargetsPath></FSharpTargetsPath>
                  </PropertyGroup>
                </Otherwise>
              </Choose>
            </Otherwise>
          </Choose>
        </Otherwise>
      </Choose>
    </Otherwise>
  </Choose>
  <Import Condition="'$(FSharpTargetsPath)' != ''" Project="$(FSharpTargetsPath)" />
  <Target Name="BeforeBuild">
    <Message Condition="'$(FSharpTargetsPath)' == ''" Importance="High" Text="F# SDK path was not found!" />
  </Target>

这应该适用于所有版本。

关于visual-studio-2013 - 如何制作在 VS2010/VS2013-preview 上同样工作的 F# 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17525946/

相关文章:

.net - 为什么堆栈的深度使用会导致简单解释器的超线性时间行为?

f# - 在 F# 中强制对函数进行多次计算

jboss - 我可以在 WildFly 8.2 上安装 apiman 1.0.0.Beta1

c++ - 导入库<->动态链接库兼容性

javascript - 忽略 typescript 错误 "property does not exist on value of type"

visual-studio - Settings.settings中的:"The method or operation is not implemented."错误

visual-studio-2013 - 当程序集路径包含空格时,无法在 Visual Studio 2013 中分析测试

dll - 在 Visual Studio 2013 中添加对您自己的 DLL 项目的依赖项/引用

f# - 如何在 Prop 更改时取消 Cmd.OfAsync?

python - 模拟 python ctypes byref 参数 2 pre 2.6