Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different behavior when running Fsc in FAKE vs fsc.exe #689

Closed
pavelm opened this issue Mar 11, 2015 · 9 comments
Closed

Different behavior when running Fsc in FAKE vs fsc.exe #689

pavelm opened this issue Mar 11, 2015 · 9 comments

Comments

@pavelm
Copy link

pavelm commented Mar 11, 2015

I'm seeing an error when running the Fsc build on an fsx file, but it successfully compiles when running fsc.exe.

fsc -I:bin/Debug test.fsx
vs

[ "test.fsx" ] |> Fsc (fun p -> { p with OtherParams = [ "-I:bin/Debug" ] } )

unknown (1,1)-(1,81) typecheck error The module/namespace 'System.Runtime.CompilerServices' from compilation unit 'mscorlib' did not contain the namespace, module or type 'ExtensionAttribute'

(I am using an extension method defined in a referenced library)

Could this be a versioning issue?

@forki
Copy link
Member

forki commented Mar 12, 2015

The Fsc task uses the FCS. What's inside test.fsx?

@forki
Copy link
Member

forki commented Mar 12, 2015

(most people still use the MSBuild task and compile the whole fsproj or even the sln)

@pavelm
Copy link
Author

pavelm commented Mar 12, 2015

I was able to reproduce with a simple project, see repo: https://github.com/pavelm/CompileFsx

running with FAKE triggers the problem, but using fsc.exe works fine

@pavelm
Copy link
Author

pavelm commented Mar 13, 2015

@forki I found a work around by using the --noframework argument along with explicitly specifying the framework libraries.

    let framework = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.3.1.0\FSharp.Core.dll"
    let mscorlib = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll"
    let system = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll"
    let systemCore = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll"

    [file]
    |> Fsc (fun p ->
        {p with OtherParams = [ "--noframework"; "-r"; framework; "-r"; mscorlib; "-r"; system; "-r"; systemCore] } )

Seems like FSC is using an older mscorlib and/or FSharp.Core because of the ExtensionAttribute. Works fine for dlls which don't expose any extension methods.

wk-j added a commit to lllife-fsharp/soundcloud-dl that referenced this issue Oct 24, 2015
@ghost
Copy link

ghost commented Nov 30, 2015

I ran into the same issue, but it looks like a Fw 4.0 - 4.5 problem. i googled and found some similar issues. Is there any way to fix it without referencing an specific fsharp.core and mscorelib? I ask this 'cause when you use the --noframework you must reference other core libs like System.Numerics (also @pavelm shows us an example in the comment above) and, IMO, this add too much noise to build script files.

@matthid
Copy link
Member

matthid commented May 6, 2017

I guess the Fsc task should provide a "tool" property where you can override the executed tool (to execute an external fsc.exe instead of the bundled FCS)

@vanceism7
Copy link
Contributor

I can work on this @matthid

@matthid
Copy link
Member

matthid commented May 4, 2018

@vanceism7 yes please feel free to send a pr, help is wanted on this ;)

matthid added a commit that referenced this issue May 11, 2018
@matthid
Copy link
Member

matthid commented May 19, 2018

As we now have the FSC module for fake 5 please report any issues the new module has

@matthid matthid closed this as completed May 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants