Custom help in SharePoint 2010 is not difficult to install, once you’ve been through it. I found some helpful blogs for using the SharePoint utility HCInstall. However, I didn’t want to use a command-line utility on a FeatureActivated receiver. So I decided to dig into it and see if I couldn’t just do in code what it does. If you intend to install help thru an install script, use the utility provided by Microsoft. If you intend to install help thru features (ie, install help on demand as needed), then this post is for you.
If you haven’t used HcInstal, no worries. I’d like to walk thru what the HCInstal.exe code does. It’s not a lot, actually. You can use it as a stand-alone utility. Or, you can drop it in your project with a Reference.
By doing so, you’ll need a using declarative, namely Microsoft.SharePoint.Help.HcInstaller.
The real work is done in ParseArgs and StartIt().
* ParseArgs() does just that, parses the command line arguements, or your arguements if you’ve referenced the EXE in your project and utilized the HcInstaller_Main class’ Main() method.
* StartIt() then uses the SharePoint help object model. Did you know that it existed? In the online SharePoint 2010 SDK, found on MSDN here SharePoint help, there is little reference to it. [Notice it’s found in the Administration section. However, the namespace is not within the Administration namespace, and the dll containing the namespace is not the Admin dll, either, it’s just the Microsoft.SharePoint.dll. Back to our work…] So StartIt() then does the work based on the arguments. If you chose to install a help file, then it calls the Microsoft.SharePoint.Help.SPHelpMerge() method. The SDK content is here, SPHelpMerge. Notice there is no SP2010 version of this SDK helpfile, which is a bummer. But that’s okay, it appears that nothing has changed in it.
The SPHelpMerge class has 4 main methods.
In my current testing, I have not found UninstallOneHelpCollection to work. So, on my vm, I’m using UninstallAllHelpCollections for removing the help collections. I’ve noticed this carries thru to hcinstal.exe ( hcinstal.exe /act uninstallonehelpcollection) as well. If anyone has any info on this, I’d appreciate it.
For now, however, I’m using the SPHelpMerge.InstallOneHelpCollection() and it’s working great. If you need a sample help collection to install, you can start with this one from Code Project
Using the SPHelpMerge class, you’ll have code like this:
The parameters are hardly documented. Changing most of them did not affect my install.
And there you have it. It only takes a couple of lines of code to install your help content file! Now you can include these lines into a Farm-scoped feature wrapped up in a Visual Studio SharePoint Feature project, and viola!