What are my options for sharing code between DNX / ASP.NET 5 projects (project.json / xproj) and other C# projects (csproj) within a single solution?

Solution 1:

Take a look at what EntityFramework does.

They target 3 TFMs: net45, .NETPortable,Version=v4.5,Profile=Profile7, frameworkAssemblies and they have both csproj and xproj in the same folder.

Basically, for each project you have two project files.

However I cannot find a way to reference ClassLibrary-dnx from WindowsService.csproj.

Unfortunately, that's not possible, yet. You can only reference csproj from xproj, not the other way around. You have two alternatives: (1) have both xproj and csproj like EF does or (2) reference the NuGet package from csproj.

If you want to do alternative (2) then you can set the output of the xproj to a folder and add that as a NuGet feed.