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