Package Creator - Require a Dependency

2019-07-22 03:55发布

What is best practice for the Package Creator to either require a dependency of another package, i.e. the Forms Rendering package, or install the required dependency. The configuration packages are available from Package Creator but that appears tedious if a package has numerous config items.

标签: c1-cms
1条回答
不美不萌又怎样
2楼-- · 2019-07-22 04:50

The current release of Composite C1 Package Creator (v.3.3) do not have features for specifying required packages via the UI. I suggest you register a feature request for this and describe your need. You can use 'Create New Item' on http://compositec1.codeplex.com/workitem/list/basic

Writing custom validation logic

With some C# development you can add this check to a package though. The C1 Package system is based on 'installer plug-ins' that validate state before install and do the install work. You can write such an 'installer plug-in' and make it validate the presence of a required C1 Package and then associate your plug-in with your package.

  1. Create a class that inherit from Composite.Core.PackageSystem.PackageFragmentInstallers.BasePackageFragmentInstaller

  2. Override Install() and Validate() - put your validation into Validate() and return one or more PackageFragmentValidationResult is your validation fails. Let Install() simply return.

  3. Register your new 'fragment installer' class in the packages install.xml file - add a section like this inside the root element:

    <mi:PackageFragmentInstallerBinaries> <mi:Add path="~/MyAssembly.dll"/> </mi:PackageFragmentInstallerBinaries>

    where path points to your assembly as you added it to the zip.

  4. Inside the existing <PackageFragmentInstallers /> element, add calls to your class inheriting from BasePackageFragmentInstaller by using an element like <mi:Add installerType="MyFragmentInstallers.MyValidator, MyFragmentInstallers"/>

Doing this will make Composite C1 call your Validate() method as part of the package install, and alert the user if any validation messages are returned.

Detecting if a package is installed

If you know the ID of a package, you can check if it has been installed using Composite.Core.PackageSystem.PackageManager.IsInstalled(Guid packageId).

查看更多
登录 后发表回答