Adding .NET Core Multi-target to a .NET Framework library

341 Views Asked by At

I have a .NET Framework library with NuGet package dependencies. This library is consumed exclusively by .NET Framework projects. Some of them by local project references, and most through NuGet. I publish the library to a private NuGet server.

A few projects have cropped up using .NET Core based infrastructure, and I would like to make my standard library available to these projects. I am not switching any of the existing infrastructure to .NET Core. I don't want to introduce .NET Core dependencies into every existing .NET Framework project. I have noticed that when I install certain multi-targeted libraries, sometimes they include "netstandard" or something like that -- and install lots of dependencies. These are unacceptable and get immediately uninstalled from .NET Framework projects.

Is it possible to multi-target my .NET Framework (4.72 if it matters) project to .NET Core as well, while still producing native .NET Framework libraries? I can copy and paste all the code in my library into a netcoreapp3.1 project, install NuGet dependencies, and that code runs fine. However, I don't want to port this library to .NET Core, and then multi-target it back to .NET Framework. As far as I am aware, that is not the same as having a native implementation. I just want to be able to use the library in a .NET Core app without copying and pasting the entire library, and letting the versions get out of sync. The less ceremony the better.

My csproj file doesn't have a <TargetFramework or <TargetFrameworks> property. It has a <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> property.

Is what I'm trying to do possible? I can't tell from the documentation I have read.

0

There are 0 best solutions below