views:

453

answers:

4

I may have this completely wrong, but my understanding is that the --standalone compiler option tells the compiler to include the F# core and other dependencies in the exe, so that you can run it on another machine without installing any 'runtime'.

However, I can't get this to work in the CTP - it doesn't even seem to change the size of the output file (docs I've read say about 1M extra).

"Google may know, but if it does, it ain't telling, or I'm not looking in the right place"

UPDATE:

It seems to work with latest CTP update 1.9.6.2

UPDATE2:

I have since experienced another error:

FSC(0,0): error FS0191: could not resolve assembly Microsoft.Build.Utilities.

If you get errors like this when trying to compile --standalone, you need to explicitly include them as references in your project.

+1  A: 

F# manual: Statically linking the F# library using "--standalone"

Did you try to run peverify.exe utility?

aku
"All Classes and Methods in MyApp.exe Verified."From what I understand (i.e. not much), peverify.exe only checks the internal coherence and 'type safety' of the exe. E.g. it only checks that the standalone has been done correctly, not whether it has been done at all.
Benjol
A: 

@Benjol,

just tried it myself. it seems to be broken :(

--staticlink is not working either:

C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll"
-r C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll --target exe --fullpaths  
--staticlink "C:\Program Files\FSharp-1.9.6.0\bin\FSharp.Core.dll" Tutorial.fcs

gives me:

error FS0192: internal error: Assembly C:\Program Files\FSharp-1.9.6.0\bin\FShar p.Core.dll not found in dependency set of target application, ignoring Please build a small example that reproduces this problem and report it to fsbug [email protected].

But in runtime I receive:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass embly 'FSharp.Core, Version=1.9.6.0, Culture=neutral, PublicKeyToken=a19089b1c74 d0809' or one of its dependencies. The system cannot find the file specified.

I guess we need to wait for the next CTP :)

aku
+3  A: 

Answer from MS:

There is a CTP update 1.9.6.2 that fixed some --standalone bugs.

I'm reinstalling now...

UPDATE: Works for me - so the my accepted answer is download CTP update 1.9.6.2.

Benjol
+1 vote for dealing with MS :)
aku
A: 

This has been a pet hatred of mine for a long time (it has been broken in every CTP release ever including the latest 1.9.6.16 May 2009 release). The "solution" is essentially to write your own build system that is not broken.

This is a real problem for me because I have accumulated hundreds of great F# programs that I would like to put on our site but it takes hours to build each one into a standalone executable.

Jon Harrop
Who voted down without explaining why?
Benjol
Probably that banker I exposed for lying about his accomplishments.
Jon Harrop