Investigate if and how FSharp.Compiler.Tools can override FSharpTargetsPath

This repository was archived by the owner on Jan 3, 2023. It is now read-only.

This repository was archived by the owner on Jan 3, 2023. It is now read-only.

@0x53A

Description

Currently the targets is always taken from the (assumed to be) installed visual studio. It should be possible to include Microsoft.FSharp.Targets in the nuget and use that.

Ref dotnet/fsharp#2575
Ref #675

If you want to use the targets file from the nuget package, you can replace

  <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)" />

with

  <PropertyGroup>
    <FSharpTargetsPath>$(FscToolPath)\Microsoft.FSharp.Targets</FSharpTargetsPath>
  </PropertyGroup>
  <Import Project="$(FSharpTargetsPath)" />