The problem here is that it is an unpublish operation and no templates are executed and we cannot use the AddInstructions method available in the RenderedItem class.
As an alternative there is a non documented extension point called a TransportHandler, you need to implement the ITransportHandler interface that is located in a GAC assmebly Tridion.ContentManager.Publishing.Transporting.dll
.
This interface gives you access to the TransportPackage and you can manipulate it when an item is certainly unpublished.
Here a code sample.
public class CustomTransportHandler : ITransportPackageHandler {
private XmlDocument _instructionsDocument;
public CustomTransportHandler(TransportPackage package) {
_instructionsDocument = package.InstructionsDocument;
}
public void HandleItemForPublishing(object item, XmlElement parentElement) {
throw new NotImplementedException();
}
public XmlElement HandleRenderedItemForPublishing(RenderedItem renderedItem, XmlElement parentElement) {
throw new NotImplementedException();
}
public void HandleResolvedItemForUnPublishing(ResolvedItem resolvedItem) {
XmlElement customElement = _instructionsDocument.CreateElement("CustomElement");
customElement.InnerText = "CustomValue";
}
}
You can configure it in the Tridion.ContentManager.config file.
<transporting rootStorageFolder="c:\Temp">
<mappings>
</mappings>
</transporting>
I hope this helps.