Generate C# code with Roslyn and .NET Core

Is there a way to generate C# code using Roslyn with .NET Core. I've tried using the SyntaxFactory from the package Microsoft.CodeAnalysis.CSharp. The problem I'm currently stuck with is getting proper formatted code as text from it.

The problem here is, that they all use the package Microsoft.CodeAnalysis.CSharp.Workspaces which isn't compatible with .NET Core at the moment. Are there any alternative routes or workarounds for using Roslyn as a code generator with .NET Core?

The package Microsoft.CodeAnalysis.CSharp.Workspaces 1.3.2 supports netstandard1.3, so it should be compatible with .Net Core. But it depends on Microsoft.Composition 1.0.27, which only supports portable-net45+win8+wp8+wpa81. This framework moniker is compatible with .Net Core, but only if you import it in your project.json.

That means that to make this work, the relevant sections of your project.json should look like this: