Search code examples
c#pythonscons

Adding C# support to SCons on Mac


I found C# support for SCons (https://bitbucket.org/russel/scons_csharp/overview), but I don't know where to install (copy) the python scripts are copied into.

I installed Scons with brew command, so I have /usr/local/Cellar/scons/2.3.4 directory on my Mac.

enter image description here

What should be the next step to install the C# builders?


Solution

    1. Create a directory ~/.scons/site_scons/site_tools.
    2. cd ~/.scons/site_scons/site_tools
    3. hg clone https://bitbucket.org/russel/scons_csharp

    Change one line (460) from csharp.py (~/.scons/site_scons/site_tools/scons_csharp/csharp.py).

    env['CSC']          = env.Detect('mcs') or 'csc'
    

    We need this change because the default setting for compiler (gmcs) is outdated.

    Create build file: SConstruct.

    env = Environment(
       tools=['scons_csharp']
    )
    
    sources = ['Hello.cs']
    prog = env.CLIProgram('myapp', sources)
    

    Execute scons -Q to get:

    mcs -nologo -noconfig -out:.../myapp.exe Hello.cs
    

    References