29

I have an application targeting .NET Framework, and now I need to develop a library in .NET Core. I plan to put both projects in the same solution and add the .NET Core library as a reference in the .NET Framework project.

Can this be done? If the answer is yes, how can this be done?

denfromufa
  • 4,995
  • 11
  • 66
  • 130
vKint
  • 291
  • 1
  • 3
  • 4
  • I don't know whether this can be done; my guess is "no." But if you're using source control of some sort, you could copy the library to a separate directory in source control, check it out, modify the project type, and pull *that* project into your solution, then keep the two projects in sync via source control... – adv12 Oct 10 '16 at 13:32
  • It is not possible to reference a xproj from a csproj directly. You have possiblty to Deploy the xproj as a NuGet package and use the NuGet package in your csproj. – Raskolnikov Oct 10 '16 at 13:40
  • Every time I modify the code of the library I have to build it, create the NuGet package, unintall the current version and than install the new one in the .Net Framework project, right ? – vKint Oct 10 '16 at 13:47
  • .NET Standard provide common platform for Asp.Net Core, Asp.Net Framework and Xamarin. Some helpful links [Intoducing .Net Standard](https://blogs.msdn.microsoft.com/dotnet/2016/09/26/introducing-net-standard/) [Msdn .Net Standard][2] [2]: https://docs.microsoft.com/en-us/dotnet/standard/net-standard – Khalil Jul 28 '17 at 22:44

1 Answers1

17

There is an article published in April 2017 on how to support both runtimes from the same solution:

https://docs.microsoft.com/en-us/dotnet/core/porting/project-structure

It boils down to 2 methods:

  • Having both frameworks configured in the same project (e.g. *.csproj):

Replace existing projects with a multi-targeted .NET Core project.

  • Having a separate project for each framework:

Keep existing projects and create a .NET Core project.


We are actively discussing which way to go in pythonnet, since the project supports .NET Framework on Windows and Mono on Linux/OSX. Now we are adding cross-platform pythonnet support:

https://github.com/pythonnet/pythonnet/pull/518

denfromufa
  • 4,995
  • 11
  • 66
  • 130