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