Search code examples
c#.netasp.net-corednx.net-core

.NET Core: How to use csproj-based projects alongside project.json?


Is there a (preferably convenient) way to setup a C# project such that it uses both the project.json-based format introduced with .NET Core, and a traditional csproj project file? If so, how?

I'm curious because it appears this is what they do in the CoreFX repo, instead of using the xproj-based format that is generated by Visual Studio.


Solution

  • Aha! It looks like I found the answer by myself in Visual Studio.

    Instead of creating a Class Library (Package) project (which may be tempting because of the flashy blue icon), just create a regular PCL:

    When prompted for the platforms you want to target, simply include ASP.NET Core 5.0 as one of them:

    Then Visual Studio will auto-generate both the csproj and project.json files for you, and you can live happily ever after without having to (God forbid) write your own csproj file.

    Full instructions can be found here on the CoreFX repo.