In these days I'm starting to move some projects from Delphi 7 to Delphi 2006. Therefore I started to install all the required libraries in Delphi 2006. And I found out that many libraries don't use packages properly. Beyond the runtime/designtime issue, many libraries don't set the options properly to share the same code among different versions of Delphi. Once I was used to keep different copies of each library in each Delphi folders, in a folder named "3rd". Later I changed approach, because some libraries (Developer Express, JCL/JVCL just to name a few) come with nice installer that will install libraries for each installed Delphi release, sharing the same source code. Also, having libraries in a "privileged" directory structure like <program files> was not a good idea, from a security point of view. Now I store all library in a "dlib" folder, with proper permission. But with several libraries I found some issues still - after ten Delphi releases:
- Libraries that do not put .dcu files in separate directory for each Delphi version
- Libraries that do not add Delphi version informations to compiled packages using package options instead of putting them in the filename
- Libraries that have version informations in the .dcp filename.
Put dcu files in separate directories Like any project, packages have a Unit output directory setting. Please create separate directory for each supported Delphi version, i.e. /dcu/D7, /dcu/D10 and set it in the corrisponding package. When a package is compiled its dcu will go in the proper path. The source code could be still shared among different releases of Delphi.
Add version information to packages using package options, not the filename. Since when packages were introduced, they have version information in the file name: vcl30.dpl, vcl70.bpl, etc. While in the early releases that had to be in the source file name too, making a bit complex to manage included packages, later that become an option in the project setting. Just add the proper one and the compiler will generate the proper file name. Packages can't be shared among different Delphi versions, there no reason not to do it. IMHO is better to follow the Delphi standard and add the Delphi version as the last part of the file name. If you need version information for your package, add them before the Delphi version. But I think incompatible packages should have whole different names. If you need release informations, they could be added in the file resources - installers can use them better than informations put in file names. Following these very simple rules will make moving from a release to another just a matter of compiling packages, and will avoid headaches because the wrong files are found in the wrong places.
Do not put version informations in the .dcp filename. The dcp filename is used to reference the package in the requires clause of other packages, and in the run-time package list of applications. If the filename contains the version informations, everytime the package is upgraded, the developer is forced to hunt down and update each reference.