Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.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.

like image 440
James Ko Avatar asked Feb 16 '16 18:02

James Ko


1 Answers

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.

like image 137
James Ko Avatar answered Sep 28 '22 08:09

James Ko