Say I have a solution with several projects included. One of projects is Main (where general code and APIs are placed) and the rest are kind of extensions (Extension1, Extension2, Extension3) for the Main and use third-party libraries. Now I'm making the solution compatible on both Full Framework and .Net Core Framework.
The solution had already had conditional building process depending on target framework before I started adding support for .Net Core, so I have no problems with conditional building yet.
The problem what I do have is that part of third-party libraries is not compatible with .Net Core yet. That makes a part of the extensions incompatible with .Net Core. The only option that comes to my mind is to have separate solutions and code bases for full framework and .Net Core Framework. BUT I would like to have same code base in both cases because my code is pretty compatible with both frameworks and otherwise it would be such a pain in the neck to support.
Is it possible to have only one solution for that case and be able to build (Main + (Extension1, Extension2, Extension3)) projects for full framework and (Main + (Extension1, Extension2)) for .Net Core Framework? If it's not, what options do I have?
Thank you all in advance
You want to be looking into .NET Standard - I'd also take a look at the videos put out by Immo Landwerth about it.
The tl;dr is that .NET Standard lists the APIs and methods which you can expect a .NET application (Framework, Core, WPF, Xamarin, etc.) to have access to. Higher version numbers of the standard include more APIs but reduce the number of frameworks you can use (Framework, Core, WPF, Xamarin, etc.).
Here's a visual of how .NET Standard is adopted and supported by the different frameworks.
![](https://www.manongdao.com/static/images/pcload.jpg)
Along the top are the versions of .NET Standard, and down the left are the versions of the frameworks. Using this chart, you can see that .NET Standard 2.0 is supported by:
- .NET Core 2.0
- .NET Framework 4.6.1
- Mono 5.4
etc.
This means that any application which targets any of those frameworks will have access to the APIs listed in .NET Standard 2.0.
In your example, you could have all of your business logic in .NET Standard compatible libraries (regardless of whether they are Framework or Core) and have two separate Main projects (one for Framework and one for Core).
This could be done with three separate solutions:
- One for your .NET Standard class libraries
- One for your .NET Framework Main (which includes the .NET Standard class libraries)
- One for your .NET Core Main (which includes the .NET Standard class libraries)
You could also build the .NET Standard class libraries as a NuGet package (with or without hosting them externally) and pull them into your two (.NET Framework and .NET Core) Main solutions.