Have you ever uploaded a Dynamics CRM Plug in and then later wanted to get the assembly that was uploaded? The following steps are to modify the Plugin Registration Tool found in the CRM SDK to allow export of assemblies once they are uploaded.
1. In the file OrganisationHelper.cs
Modify the GetColumnSet method
case PluginAssembly.EntityLogicalName:
// Develop1:Download Assembly Support
cols.AddColumns("name", "createdon", "modifiedon", "customizationlevel", "pluginassemblyid", "sourcetype", "path", "version", "publickeytoken", "culture", "isolationmode", "description","content");
2. In the file CrmPluginAssembly.cs
Add the following code to the class:
// Develop1
private string _content;
public void ExportAssembly(string path)
{
byte[] assembly = Convert.FromBase64String(this._content);
File.WriteAllBytes(path, assembly);
}
3. In the file CrmPluginAssembly.cs
Add the following code at the end of the RefreshFromPluginAssembly method:
// Develop1:Download Assembly Support
if (assembly.Content != null)
{
this._content = assembly.Content;
}
4. On the PluginRegistrationForm Form
Add a button next to the Load Assembly command button with the following properties:
Text: Export Assembly
Name: cmdExport
5. Double click on the button to get to the event code:
// Develop1:Download Assembly Support
private void cmdExport_Click(object sender, EventArgs e)
{
this.m_currentAssembly.ExportAssembly(txtAssemblyPath.Text);
MessageBox.Show("Assembly exported.");
}
To use, you'll need to double click on a plugin assembly to bring up the properties page. Enter a file path (e.g. C:\ExportedAssembly.dll) Ddon't use the browse button since this wlll load an assembly. Click 'Export Assembly' to export your assembly.