How to use a specific version of the F # compiler in MSBuild projects?

I have F # project files created using visual studio.

On my computer, which has several versions of F #, it seems to be picking the latest version.

However, I want to use a specific F # compiler - one that is installed using version 3.1.2.

How can I do it?

+6
source share
1 answer

I use a similar setting, I just use the F # compiler from the nuget package - this works better in general to build environments.

.props, F #, fsharp_project.props. , F #. :

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PackageRoot>C:\packages\Fsharp.Compiler.Tools.Nuget</PackageRoot>
    <FscToolPath>$(PackageRoot)\tools</FscToolPath>
    <FSharpVersion>v3.0</FSharpVersion>
  </PropertyGroup>
  <ItemGroup>
  <Reference Include="FSharp.Core">
    <HintPath>$(PackageRoot)\tools\fsharp.core.dll</HintPath>
  </Reference>
  </ItemGroup>
</Project>

F #, , .

.fsproj, :

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <Import Project="C:\whereever\fsharp_project.props"/>
...

.fsproj FSharp.Core.dll. - , .

, fsc.exe, .

: .props FSharp.Core.dll # F #, . , FSharp.Core.dll .csproj, # , `.props '.

+4

Source: https://habr.com/ru/post/1017069/


All Articles