#2541 Compiling to DLL

elyashiv Tue 31 May 2016

I'm trying to compile a project to a DLL, and can't really get through. I started by inheriting from Build::BuildCS, and this worked. next I needed to define the dotnetHomeDir, witch was trickier - I'm using linux and mono, and what I did was to define it as the working dir and I created a link to mono-csc called csc.exe.

Now when I try to run the build script I get this Err:

compile [...]
  CompileCs
ERR: CompileCs failed
BUILD FAILED [38ms]!

not so helpful. This helpful message comes from the swallowing of the whole err here: http://fantom.org/doc/build/src-CompileCs.fan#line40

I tried changing this line by inheriting and changing the function, but to many functions are private, so I will need to copy them as well :(.

Can someone help me compile to DLL?

EDIT

I managed to compile with my own classes inherited from the regular ones, and found out what's the problem - for some reason cmdExe is just csc.exe without the path. I'm not sure how. I changed the dotnetHomeDir to real path and not relative, and now I get:

error CS2008: No files to compile were specified

though I set srcDirs...

elyashiv Tue 31 May 2016

Oops, seems like I'm using the wrong class - BuildCs is used to compile C# code. How can I compile to a dll?

SlimerDude Tue 31 May 2016

Sorry elyashiv, I've never tried the CLR part of Fantom - it's something I keep meaning to try though.

andy Tue 31 May 2016

Your dotnetHome is going to be the installation path of .net/mono - its specified under etc/build/config.props or as a env var:

dotnetHome=/C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/

What are you trying todo? If its just create peer classes - look at inet pod - all you need todo is specify the dotnetDirs in your build.fan script. If your trying to compile to a standalone DLL I'm not sure that works.

And in either case your milage may vary - the .NET side has not kept pace with the JVM/JS targets - but please post what you find so we can take note.

elyashiv Wed 1 Jun 2016

The reason I have created a soft link is because the binary in mono has a different name than the one in VS, so I just created a link to overcome this.

What I'm trying to do is to create a DLL from fcode, but it seems to be there is no standard way to do so - java has JarDist, .NET doesn't have a equivalent.

I guess somewhere in the source for sys there is code that transforms fcode to CIL that I can use, just need to dig in. (EDIT - the place is in sys/src/dotnet/sys/fanx/emit)

andy Wed 1 Jun 2016

Yeah I don't believe we ever created that - might not be too hard to work up a BuildDll build task - I can work with you if you wanted to take a stab (been awhile since I was in that code - so my dotnet is a bit rusty :)

Login or Signup to reply.