In this post, let us see how to create Revit Manifest files programmatically. It is necessary many times and especially important for Revit addin installers.
In development environment, it is not a bad idea to hard code the paths of debug version addin assemblies in manifest files, just as various wizards, coders and widgets of RevitAddinWizard do, to save time; however in product environment, doing so is obviously inconvenient and inflexible for users and unprofessional for software itself.
So it is introduced here an easy to use and functional method which can help create a Revit manifest file on the fly:
void CreateManifestFile(string filename, string assembly, string classname, string id, string appname)
{
using (StreamWriter writer = new StreamWriter(filename, false, Encoding.UTF8))
{
writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
writer.WriteLine("<RevitAddIns>");
writer.WriteLine(string.Format("\t<AddIn Type=\"Application\">"));
writer.WriteLine(string.Format("\t\t<Assembly>{0}</Assembly>", assembly));
writer.WriteLine(string.Format("\t\t<FullClassName>{0}</FullClassName>", classname));
writer.WriteLine(string.Format("\t\t<ClientId>{0}</ClientId>", id));
writer.WriteLine(string.Format("\t\t<Name>{0}</Name>", appname));
writer.WriteLine(string.Format("\t</AddIn>"));
writer.WriteLine("</RevitAddIns>");
}
}
As can be seen the above works for Application addin types only but can be easily extended to cover Command types as well. Regarding the StreamWriter code, I’d like to point out the encoding matter again. The Encoding.UTF8 enum value has to be used here to be consistent with the XML encoding as declared in its header; otherwise tricky issues may just occur.
If the following test code is given:
CreateManifestFile(@"c:\temp\Test.Addin", @"c:\temp\Test.Dll", @"TestNamespace.TestClass", Guid.NewGuid().ToString(), "TestApp");
a manifest file with the following content will be created:
<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Application">
<Assembly>c:\temp\Test.Dll</Assembly>
<FullClassName>TestNamespace.TestClass</FullClassName>
<ClientId>0db6baba-16e3-443c-aca6-f73997a326b3</ClientId>
<Name>TestApp</Name>
</AddIn>
</RevitAddIns>
Simple and cool, isn’t it?
And better, it does not bring in any dependencies.
Revit Manifest Register of RevitAddinWizard helps create an installer custom action project flexibly in no time. The action will automatically create a manifest file, append proper path to the specified assembly, and deploy the file to the right Revit Addin roaming folder during installation.
Related posts:
Deploy & Install: Revit Application Addin Manifest
Deploy & Install: Revit Command Addin Manifest
Deploy & Install: Revit Addin Roaming Folders
Deploy & Install: The Registry of Revit 2011
Deploy & Install: The Registry of Revit 2012
Deploy & Install: Where Are Revit Products Installed
Deploy & Install: Manifest Navigator of RevitAddinWidget
Deploy & Install: RegEdit Launcher of RevitAddinWidget
Deploy & Install: Revit Locator of RevitAddinWidget
Deploy & Install: Manifest Encoding
Deploy & Install: Manifest Loading
Deploy & Install: Manifest ClientId
Deploy & Install: Manifest ClientId and AddinId
Deploy & Install: Manifest Integrity
Deploy & Install: Revit Manifest Organizer
Deploy & Install: Create New Of Revit Manifest Organizer
Deploy & Install: Check Integrity New Of Revit Manifest Organizer
Deploy & Install: Detect Duplicate New Of Revit Manifest Organizer
Deploy & Install: View Selected Of Revit Manifest Organizer
Deploy & Install: Edit Selected Of Revit Manifest Organizer
Deploy & Install: Merge Selected Of Revit Manifest Organizer
Deploy & Install: Dismantle Selected Of Revit Manifest Organizer
Deploy & Install: Copy/Move/Delete Selected Of Revit Manifest Organizer
Deploy & Install: Miscellaneous Of Revit Manifest Organizer
Deploy & Install: Create Revit Manifest Files Programmatically With C#
Deploy & Install: Programmatically Detect Windows Versions And Find Revit Addin Roaming Folders
Deploy & Install: Revit Addin Project Output And API Dependencies
Deploy & Install: Revit Addin Projects and Visual Studio Setup Custom Actions
Deploy & Install: Deploy Revit Manifest Files with C# Using Installer Custom Actions
Recent Comments