2

on Windows using Visual Studio 2015, I can compile a project with dnu build. The project.json file looks as follows:

{
  "version": "1.0.0-*",
  "description": "My Class Library",
  "authors": [ "Class Library template" ],
  "tags": [""],
  "projectUrl": "",
  "licenseUrl": "",
  "tooling": {
    "defaultNamespace": "Common"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-*",
        "System.Collections": "4.0.11-beta-*",
        "System.Linq": "4.0.1-beta-*",
        "System.Runtime": "4.0.21-beta-*",
        "System.Threading": "4.0.11-beta-*"
      }
    }
  }
}

After installing mono, dnvm and dnx on a Mac, as per this tutorial, I can actually compile the same project on OSX! This in itself is already pretty awesome!

now, I added the following framework to my project.json file:

"frameworks": {
    "dnx35": { }, //"net35"
    "dnx451": { },
    "dnxcore50": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-*",
        "System.Collections": "4.0.11-beta-*",
        "System.Linq": "4.0.1-beta-*",
        "System.Runtime": "4.0.21-beta-*",
        "System.Threading": "4.0.11-beta-*"
      }
    }

This still compiles on Windows, and produces three sets of dlls, as expected.
However, on OSX it does not build the dnx20 target. Though as far as I understand, the mono compiler mcs can be set to target .net35 by passing in a sdk parameter.

So my question is: Can I target .NET35 with dnx on OSX using mono?

EDIT The goal of this question is to compile a set of dll's that can be imported into Unity3d. And because Unity3d uses mono as a runtime, I would like to be able to do that by using dnu build, as to be able to develop these dll's on any platform.

RoelF
  • 7,483
  • 5
  • 44
  • 67
  • I would highly recommend trying CoreCLR instead of Mono. A lot of work have been done to make sure that the OSX/Ubuntu scenario works. – Maxime Rouiller Nov 26 '15 at 15:04
  • Another question. Why target 3.5 on OSX if you have `dnxcore50` working? `dnxcore50` will support OSX/Linux/Windows without an issue. – Maxime Rouiller Nov 26 '15 at 15:06
  • good question! Didn't mention that in the answer. The dll's which are produced need to be used by Unity3d 5.x, which used mono, and therefore need to be .NET 3.5 compatible. – RoelF Nov 26 '15 at 15:41
  • Have you tried using `net35` instead of `dnx35`? I think JSon.NET uses it (as per https://github.com/aspnet/dnx/issues/1894) – Pawel Nov 26 '15 at 20:02
  • I did indeed try `net35` as well, but same problem (on Windows it doesn't make a difference) – RoelF Nov 26 '15 at 21:07

1 Answers1

1

You can pass custom Rosyln compiler options via compilationOptions in the project.json file:

"compilationOptions": {
    "optimize": true,
    "define": ["RELEASE", "TRACE", "PLAYSCRIPT"]
},

Take a look at the various project.json files in the Github aspnet/dnx project, i.e. project.json

But those options are being passed to Rosyln not mcs, Mono is being used as a CLR host for Rosyln's compiler as a service), but I do not believe you are substitute Mono's mcs for that (comments on this anyone?)

SushiHangover
  • 73,120
  • 10
  • 106
  • 165