繁体   English   中英

如何在VS2010 / VS2013-preview上制作相同的F#项目?

[英]How to make F# projects which will work same on VS2010 / VS2013-preview?

新的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预览内容之间的兼容性呢?

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

  <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>

这适用于所有版本。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM