Can I use multi-targeting to produce a reference assembly?


#1

I am currently developing a library using dependency injection to provide some features that need platform specific API (for example logging, default directory resolution, etc) but I’m curious what happened to something that I read about ages ago: the ‘ref’ folder in the Nuget spec. I can’t seem to find information on it anymore but from what I remember it let you define a sort of “delayed implementation” whereby you could build against a .NET Standard API but then when it is time to build the final product, an actual implementation gets used. It seemed to be a recognition of the old “bait and switch” technique used in the PCL model.

I just came across a blog entry about multi framework targeting and it is quite interesting. I didn’t realize it was so easy to compile multiple frameworks at once from one project but I’m wondering if I can take the output from the netstandard1.4 folder and use it in a nuget package under the “ref” folder to indicate that there is reference API available but to build it actually needs to be on one of the other listed platforms in the “lib” folder. Is that still a thing? I see the .NET Framework nuget packages doing that but I want to make sure. Actually, is there an automatic way to take the API and make it do default things (return null, etc) so that I don’t have to put a 90% implemented assembly into the reference folder and waste space?

I’m still not sure I will switch to this approach because the dependency injection model makes it easy to extend for a new platform for outside users without directly modifying the core project in a way that is potentially confusing (manually editing csproj files, etc) but I am curious anyway.


.NET Foundation Website | Blog | Projects | Code of Conduct