Skip to content

FSharp.Compiler.Tools.4.1.0 does not work with net46 fsproj in VisualStudio #721

@0x53A

Description

@0x53A

I want to use the F#4.1 compiler with VS2015.

Repro steps

Create a new F# console project in Visual Studio 2015.

Add the package FSharp.Compiler.Tools.4.1.0.

Run build.

Expected behavior

It should compile the project using the new compiler.

Actual behavior

1>------ Rebuild All started: Project: FsTest, Configuration: Debug Any CPU ------
1>	c:\users\lr\documents\visual studio 2015\Projects\FsTest\packages\FSharp.Compiler.Tools.4.1.0\build\netcoreapp1.0\fsc.dll -o:obj\Debug\FsTest.exe -g --debug:full --noframework --define:DEBUG --define:TRACE --doc:bin\Debug\FsTest.XML --optimize- --tailcalls- --platform:anycpu32bitpreferred -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.4.0.0\FSharp.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.ComponentModel.Composition.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Numerics.dll" --target:exe --warn:3 --warnaserror:76 --vserrors --LCID:1033 --utf8output --fullpaths --flaterrors --subsystemversion:6.00 --highentropyva+ --sqmsessionguid:f4681a33-2fc3-45ca-93a7-c1cdcf856afe "C:\Users\lr\AppData\Local\Temp\.NETFramework,Version=v4.6.1.AssemblyAttributes.fs" AssemblyInfo.fs Program.fs 
1>C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets(155,9): error MSB6006: "fsc.dll" exited with code -532462766.
1>Done building project "FsTest.fsproj" -- FAILED.
1>
1>Build FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

notice how it runs fsc.dll

Workaround

I edited packages\FSharp.Compiler.Tools.4.1.0\build\FSharp.Compiler.Tools.props to look like this:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>

    <!-- Default to netcoreapp fsc -->
    <FscTaskAssemblyPath>$(MSBuildThisFileDirectory)../tools/FSharp.Build.dll</FscTaskAssemblyPath>
    <FscToolPath>$(MSBuildThisFileDirectory)../tools</FscToolPath>
    <FscToolExe>fsc.exe</FscToolExe>
    <FscToolFullPath>$(MSBuildThisFileDirectory)../tools/fsc.exe</FscToolFullPath>
    
  </PropertyGroup>

</Project>

Now it correctly calls the compiler, and a simple program compiles correctly:

image

Notice how the build succeeds, even though intellisense complains about struct because it is Visual Studio 2015.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions