Mixed languages and sub-projects with .NET Core

Viewed 875

I have a project primarily written in F# that uses a component written in C#. It is building fine on Windows with Visual Studio and on Linux and OS X using Makefiles.

I'm trying to port it to .NET Core, which has its own build system, dotnet build. I'm having difficulty replicating the nested project handling of my existing build systems under it. That is, I want it to build the C# DLL, then build and link the F# executable project to it.

I tried to do without DLLs, but each project.json file can apparently only reference files in one language. If you try to add a C# file to the compileFiles list of an F# project file, dotnet build complains that it can't compile Foo.cs with fsc.

My C# project is in a subdirectory of the F# project, named after the namespace it implements, so I created a new .NET Core C# DLL project in that directory, but now I don't see how to tie the two projects together.

The dependencies feature of the project file format doesn't seem to solve this sort of problem. If the DLL project is in Foo/Bar and it implements the Foo.Bar namespace, dotnet restore fails to find it with this dependency reference:

"dependencies": {
    ...other stuff...
    "Foo.Bar": "*"
},

Apparently it can only search NuGet for dependencies. I don't want to ship the component to NuGet purely so that dotnet restore can find it.

I don't want to use bin syntax to reference the built DLL because that would require a 2-pass build and a third project.json file. (One for the F# project, one for the C# project, and one to reference the built DLL.) Even then, I still don't see how to tie the first project to the third.

Surely there's a simple way to have a nested build tree with dotnet build?

1 Answers
Related