What are common practices for designing a build system/project structure that allows targeting multiple .NET versions with different feature sets?
Specifically:
I've tried a few different ways of doing this.
I ruled out branching because it's a bit difficult to keep all the branches in sync using SVN/TFS. Distributed SCC does have more advanced support for branching/merging, so I'm planning to reconsider this approach if I ever convert.
I use conditional compilation along with version-specific projects using linked source files. The most aggressive library I've done along these lines is Nito.Linq, which hasn't been released yet. You can check out the source, though, to see how I've set up the projects. It currently targets 3.5, 4.0, SL3, and SL4, and has "with Rx" and "without Rx" variants for each of these. I had CF 3.5 working as well, but VS2010 doesn't support it.
There are a few drawbacks to this approach:
I did ask the Rx team how they handled this situation (they support 3.5, 4.0, SL3, and SL4 with the same codebase). Apparently, they use a custom in-house tool to create metadata-only versions of the runtime assemblies and then combine these into a superset-profile containing the merged metadata-only assemblies. The project is built against this superset-profile and a post-compilation "retargeting" is done to change the project's profile to one of the normal profiles.
I briefly played around with building an open-source equivalent of the Rx team's tool, but ran into too many "underdocumented" snags. It should be possible in theory, but I figured it would take way too much time for anyone without the correct contacts inside Microsoft.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With