Context
Using an API delivered as a COM reference, the goal is to build Windows-only applications targeting either .NET Framework 4.8 or .NET 6.
A library of helper methods around the API will be written and be reused across projects.
Question
What would be the best way to build this library, so that it could be used either in a .NET Framework 4.8 project or in a .NET 6 project?
So far here are the options I thought about:
- Using .NET Standard: Impossible since it is not possible to reference a COM dll in a .NET Standard project. The reason is that a .NET Standard library should warrant that it could run on every compatible target, which includes non-Windows target, on which COM makes no sense. Or am I wrong?
- The obvious one: Making two libraries, one targeting .NET Framework 4.8 and the other .NET 6. Copy/Paste code from one to the other. A little bit nasty, but it works.
- A variation: Making two libraries, again, but this time having the second library simply reference the source files of the first one, using Visual Studio feature
Add as Link. You still need to perform the adding operation in the second project every time you create a new file in the first one, so it is not fully automated. - Another variation: Making two libraries, one targeting .NET Framework 4.8 and the other .NET 6. But this time have a script (or a service, etc...) automatically mirror the source files from one project to the other.
Is there any better way to achieve this? Did I miss something?