Visual studio 2013 如何使F#项目在VS2010/VS2013预览版上运行相同?

Visual studio 2013 如何使F#项目在VS2010/VS2013预览版上运行相同?,visual-studio-2013,f#,compatibility,f#-3.1,Visual Studio 2013,F#,Compatibility,F# 3.1,新的F#项目带来了 $(MSBuildExtensionsPath32)\..\Microsoft SDK\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets msbuild失败了,所以我甚至无法基于此项目文件编写生成脚本 我的解决方案:

新的F#项目带来了


$(MSBuildExtensionsPath32)\..\Microsoft SDK\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets
$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets
msbuild失败了,所以我甚至无法基于此项目文件编写生成脚本

我的解决方案:


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

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

$(MSBuildExtensionsPath32)\..\Microsoft SDK\F\35;\ 3.0\Framework\v4.0\Microsoft.FSharp.Targets

$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v12.0\FSharp\Microsoft.FSharp.Targets
但这看起来并不是一个好的解决方案。有合适的方法吗

此外,我在运行3.0 F#compiler
fsc.exe
和类似的软件
FAKE
时遇到问题:

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


那么,如何不破坏3.0/msbuild与3.1及更新版本的VS2013预览内容之间的兼容性呢?

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

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

$(MSBuildExtensionsPath32)\..\Microsoft SDK\F#
$(MSBuildExtensionsPath32)\..\..\..\..\Microsoft SDK\F#
Framework\v4.0\Microsoft.FSharp.Targets
$(FSharpSdkPathPrefix)\4.0\$(FSharpSdkPathSuffix)
$(FSharpSdkPathPrefix)\3.1\$(FSharpSdkPathSuffix)
$(FSharpSdkPathPrefix)\3.0\$(FSharpSdkPathSuffix)

这应该适用于所有版本。

VS2013项目适用,但VS2012项目确实需要一次性升级才能使用。如果您已将VS2012项目升级到VS2013,但之后无法使用VS2012进行构建,则应报告该问题,以便为VS2013 RTM修复该问题。VS2010如何?我没有VS2012来测试这个
在那里是否有效。我不知道。VS2013预览版发布中没有提到任何关于VS2010的内容,因此我认为这意味着您将无法(轻松地)创建适用于所有3个版本的项目文件。我只是希望这一建议能够奏效,但我暂时无法确认,因为有些事情发生了变化,VS2013发布了,我再也没有2012年的安装了,所以我甚至不能自己代表这个问题。