A short-term fix, until the SDK is installed separately, should add a directive to the project file to look in the NuGet package folder for the Microsoft.FSharp.Targets file. Here are the steps I took to fix this:
Make sure you are using the new F # project from VS.NET 2017 as it has this directive:
<Import Project="..\packages\FSharp.Compiler.Tools.4.1.17\build\FSharp.Compiler.Tools.props" Condition="Exists('..\packages\FSharp.Compiler.Tools.4.1.17\build\FSharp.Compiler.Tools.props')" />
Replace this section of the project file:
<Choose> <When Condition="$(TargetFSharpCoreVersion) >= 4.3.0.0 AND $(TargetFSharpCoreVersion) < 4.3.1.0 "> <PropertyGroup> <FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup> </When> <When Condition="$(TargetFSharpCoreVersion) >= 4.3.1.0 AND $(TargetFSharpCoreVersion) < 4.4.0.0 "> <PropertyGroup> <FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup> </When> <When Condition="$(TargetFSharpCoreVersion) >= 4.4.0.0 AND $(TargetFSharpCoreVersion) < 4.4.1.0 "> <PropertyGroup> <FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup> </When> <Otherwise> <PropertyGroup> <FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\4.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup> </Otherwise> </Choose>
Using this XML:
<Choose> <When Condition="$(TargetFSharpCoreVersion) >= 4.3.0.0 AND $(TargetFSharpCoreVersion) < 4.3.1.0 "> <PropertyGroup> <FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup> </When> <When Condition="$(TargetFSharpCoreVersion) >= 4.3.1.0 AND $(TargetFSharpCoreVersion) < 4.4.0.0 "> <PropertyGroup> <FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup> </When> <When Condition="$(TargetFSharpCoreVersion) >= 4.4.0.0 AND $(TargetFSharpCoreVersion) < 4.4.1.0 "> <PropertyGroup> <FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup> </When> <Otherwise> <PropertyGroup> <FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\4.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup> </Otherwise> </Choose> <PropertyGroup Condition="!Exists('$(FSharpTargetsPath)')"> <FSharpTargetsPath>$(FscToolPath)\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup>
Make sure you create a NuGet Service Pack server to restore before you build
Make sure the package contains the file: FSharp.Compiler.Tools and FSharp.Core
The reason for this is as follows: This checks if FSharpTargetsPath exists and if it does not use the package folder as the source. You do not want to always use the package folder, otherwise when a new scan is performed on the user's computer, packages are not available, and the assembly will fail. For this to work on the build server, it is assumed that you have a step to restore the NuGet PRIOR packages to complete the build.
source share