In installers for Revit addins, it is important to not only create manifest files but also find where to deploy them. In the previous post we have talked about how to do the former; in this post we are going to address the latter.
This seemingly simple task depends on a few factors actually, one of which is caused by the Windows inconsistencies as covered in another post a while back:
Deploy & Install: Revit Addin Roaming Folders
Then how to programmatically detect which Windows the addin is trying to work with and where its manifest file should go?
Don’t worry. All these will be unveiled one by one as follows.
The .NET Framework provides a handy class which can help us detect Windows OS information such as Platform, Major Version and Minor Version.
In terms of Windows XP, its PlatformID is Win32NT, Major Version 5, and Minor Version equal to or greater than 1:
bool IsXP()
{
OperatingSystem OS = Environment.OSVersion;
return OS.Platform == PlatformID.Win32NT && (OS.Version.Major == 5 && OS.Version.Minor >= 1);
}
In terms of Windows Vista, its PlatformID is also Win32NT, Major Version 6, and Minor Version 0; Windows 7 is nothing different from Vista but with Minor Version as 1. Since roaming folder structures are the same on Windows Vista and 7, we do not have to differentiate them as far as Revit Manifest deployment is concerned:
bool IsVistaOrWin7()
{
OperatingSystem OS = Environment.OSVersion;
return OS.Platform == PlatformID.Win32NT && (OS.Version.Major == 6 && OS.Version.Minor <= 1);
}
One another factor is there are both current user and all users roaming folders in the above whichever Windows.
Here is the code to get the Revit Addin roaming folders in Windows XP, Vista, or 7:
void GetRevitAddinRoamingFolders()
{
string currentUserRoamingFolder = "";
string allUsersRoamingFolder = "";
if (IsXP())
{
allUsersRoamingFolder = Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\Application Data\\Autodesk\\Revit\\Addins\\2011");
}
else if (IsVistaOrWin7())
{
allUsersRoamingFolder = Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\Autodesk\\Revit\\Addins\\2011");
}
currentUserRoamingFolder = Environment.ExpandEnvironmentVariables("%AppData%\\Autodesk\\Revit\\Addins\\2011");
MessageBox.Show(allUsersRoamingFolder + "\n" + currentUserRoamingFolder);
}
In terms of some other Windows versions around the same time frame such as Windows 2003 and Windows 2008, we do not have to worry about them specifically because of two reasons. The first is they are not popular at all and unlikely your customers are using it; the second is that they carry the same platform/version information and also act the same as one of the Windows XP, Vista and 7.
If more details are needed, please consult MSDN documentations.
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