简体   繁体   English

安装组件的最佳方法是什么?

[英]What is the best way to install components?

Installing components under Delphi XE3 is a nightmare. 在Delphi XE3下安装组件是一场噩梦。

  • First I need to add source files to 首先,我需要添加源文件

    Tools -> Options -> Library 工具 - > 选项 - >

  • then I need to find a normal package and compile it 然后我需要找到一个普通的包并编译它

  • finally I need to find design time package and install it. 最后我需要找到设计时包并安装它。

This is just quite tedious and error prone. 这非常繁琐且容易出错。 Is there a nicer way to install components? 有没有更好的方法来安装组件?

I have found Delphi Package Installer . 我找到了Delphi Package Installer Unfortunately it doesn't support Delphi XE3 or above. 不幸的是它不支持Delphi XE3或更高版本。

I have heard that there is something similar which produces exe packages that install themselves (something like Inno Setup) but I can't find such thing. 我听说有类似的东西产生自己安装的exe包(类似于Inno Setup),但我找不到这样的东西。

No. The steps above are required. 不需要。上述步骤是必需的。

First, adding the file path to Tools->Options->Delphi Options->Library Path is so the compiler knows where to find the files to compile them. 首先,将文件路径添加到Tools->Options->Delphi Options->Library Path ,编译器知道在哪里找到要编译它们的文件。 (Actually, it's not required - you can eliminate this step by making sure that the .dpk files are in the same folder as the .pas files, and that all .pas file names are listed in the includes section in the .dpk. If the .pas files are in a different location, you'll need to either use relative paths in the .dpk (eg., MyComponents in '..\\Source\\MyComponents.pas' ) or add the location of the .pas files to Project->Options->Delphi Compiler->Search Path .) (实际上,这不是必需的 - 您可以通过确保.dpk文件与.pas文件位于同一文件夹中来消除此步骤,并且所有.pas文件名都列在.dpk的includes部分中。 .pas文件位于不同的位置,您需要使用.dpk中的相对路径(例如, MyComponents in '..\\Source\\MyComponents.pas' )或将.pas文件的位置添加到Project->Options->Delphi Compiler->Search Path 。)

The next step (finding the "normal package") is in order to build the runtime package. 下一步(找到“普通包”)是为了构建运行时包。 It's required, because the design-time package (next step) requires the code that's in that package in order to function in the Form Designer. 这是必需的,因为设计时包(下一步)需要该包中的代码才能在表单设计器中运行。 It's also needed when you decide to build your application with runtime packages, if you use the third-party components and want to distribute the runtime package for it. 当您决定使用运行时包构建应用程序时,如果您使用第三方组件并希望为其分发运行时包,则也需要它。

The separate design-time package (the third step) is required because designtime code can only be used at design-time; 需要单独的设计时包(第三步),因为设计时代码只能在设计时使用; there's nothing that can be distributed with an application if it's built with runtime packages and the package build in step 2 is one of them. 如果应用程序是使用运行时包构建的,并且第2步中的包构建就是其中之一,那么它就无法与应用程序一起分发。

This has been the way components are installed since around Delphi 3 or so, and the requirement to separate out designtime code into it's own package started being advised in Delphi 5 and enforced in Delphi 6 (when they relocated much of the IDE designtime support into their own separate packages and stopped distributing the source for them). 这是组件安装的方式,因为围绕Delphi 3左右,并且需要将设计时代码分离到它自己的软件包中,开始在Delphi 5中建议并在Delphi 6中强制执行(当他们将大部分IDE设计时支持重新分配到他们的拥有独立的包并停止为他们分发源代码)。

There really are no other options, unless the vendor supplies pre-build designtime and runtime packages for you, or supplies an installer that will do all of the above steps. 除非供应商为您提供预构建设计时和运行时包,否则实际上没有其他选项,或者提供将执行上述所有步骤的安装程序。 (Most don't.) But if you update your Delphi version, you'd still have to go through the steps above. (大多数都没有。)但是如果你更新你的Delphi版本,你仍然需要完成上面的步骤。

What about the built-in component installer? 内置组件安装程序怎么样? It is part of Delphi XE, XE2 and XE3 and a description can be found here (I wrote it). 它是Delphi XE,XE2和XE3的一部分,可以在这里找到描述(我写的)。 It will even install components in C++Builder. 它甚至可以在C ++ Builder中安装组件。 You can instal into an existing package or into a new one, which it will create for you. 您可以将其安装到现有的包中,也可以安装到新的包中,它将为您创建。

I would say that the best way to install components is to use your build manager (for example FinalBuilder) and add each component to a manager-project file which sets the necessary paths, builds the DPK files, and 'installs' the component in the IDE by making a registry entry. 我想说安装组件的最佳方法是使用构建管理器(例如FinalBuilder)并将每个组件添加到管理器项目文件中,该文件设置必要的路径,构建DPK文件,并在组件中“安装”组件。 IDE通过制作注册表项。 That way you have a documented procedure which allows you reliably to set up or repair your complete, tested, Delphi development environment. 这样,您就拥有了一个文档化的过程,可以让您可靠地设置或修复完整的,经过测试的Delphi开发环境。 You can simply re-run the project when a component has been updated and tested. 您可以在更新和测试组件时重新运行项目。 It is also quite easy to tweak an existing project to handle a new Delphi version. 调整现有项目来处理新的Delphi版本也很容易。

The big disadvantage of a vendor-supplied installer is that all the ones I have seen simply overwrite the previous version on updates. 供应商提供的安装程序的一大缺点是,我所看到的所有安装程序都只是在更新时覆盖了以前的版本。 I prefer to control the install myself, so that I have previous component source versions archived and available for comparison, in case testing reveals a problem with an upgrade. 我更喜欢自己控制安装,以便我以前的组件源版本存档并可用于比较,以防测试显示升级有问题。 The 'one-click install' sounds fine, until a minor component upgrade suddenly causes your application to stop working. “一键安装”听起来不错,直到轻微的组件升级突然导致您的应用程序停止工作。

Take a look at " Lazy Delphi Builder ". 看看“ Lazy Delphi Builder ”。 It was created to simplify build/installation of many components at once. 它的创建是为了简化许多组件的构建/安装。 It resolves packages dependencies automatically. 它自动解决包依赖关系。 Free to use. 免费使用。 Link to some old tutorial 链接到一些旧教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM