Using DataTypePackageFragmentInstaller in package install.xml
The best way is to use DataTypePackageFragmentInstaller, like this:
Using EnsureCreateStore on ApplicationStartup
In you assembly, create a class that use ApplicationStartup and in there make a call to EnsureCreateStore. This will make your data type 'self-registering' and should ensure your type exists after package install.
This approach will not un-register the data type when a package is uninstalled.
The best way is to use DataTypePackageFragmentInstaller, like this:
<mi:PackageFragmentInstallers xmlns:mi="http://www.composite.net/ns/management/packageinstaller/1.0">
<mi:Add installerType="Composite.Core.PackageSystem.PackageFragmentInstallers.FilePackageFragmentInstaller, Composite" uninstallerType="Composite.Core.PackageSystem.PackageFragmentInstallers.FilePackageFragmentUninstaller, Composite">
<Files>
<File sourceFilename="~\My.Test.dll" targetFilename="~\Bin\My.Test.dll" allowOverwrite="false" assemblyLoad="true" />
</Files>
</mi:Add>
<mi:Add installerType="Composite.Core.PackageSystem.PackageFragmentInstallers.DataTypePackageFragmentInstaller, Composite" uninstallerType="Composite.Core.PackageSystem.PackageFragmentInstallers.DataTypePackageFragmentUninstaller, Composite">
<Types>
<Type name="My.Test.Type, My.Test" />
</Types>
</mi:Add>
</mi:PackageFragmentInstallers>
The magic trick here is to have assemblyLoad="true" on the File element that copies in your assembly - this will make us pull the types from your assembly into memory and hence we are able to validate that your Type element is okay. Using EnsureCreateStore on ApplicationStartup
In you assembly, create a class that use ApplicationStartup and in there make a call to EnsureCreateStore. This will make your data type 'self-registering' and should ensure your type exists after package install.
This approach will not un-register the data type when a package is uninstalled.