7

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.

James Ko
  • 32,215
  • 30
  • 128
  • 239
  • 1
    Maybe [this blog series](http://blog.marcgravell.com/2015/11/the-road-to-dnx-part-1.html) helps. But in general, if you’re looking for a *convenient* way, you won’t find one. You should wait until the work for the dotnet CLI is done at which point the new project format is finalized and support for mixing csproj and xproj projects exists. – poke Feb 16 '16 at 18:48

1 Answers1

5

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.

James Ko
  • 32,215
  • 30
  • 128
  • 239
  • 1
    Why, what could possibly go wrong if you manually rewrite your .csproj file? :) – Tim Feb 16 '16 at 18:58
  • @Tim Nothing, except a couple hours of your time (and possibly your sanity). – James Ko Feb 16 '16 at 19:00
  • Yes, I know - sorry, was trying to inject some humor. Good find though - we haven't moved to the new core stuff, but I will keep this in mind should we find ourselves in a similar spot. – Tim Feb 16 '16 at 19:01