Sandcastle Tutorial
Here is the version of Sandcastle you will need, or whatever the most recent version happens to be when you read this:
SandCastle version 2.7 download
When you download the correct version it should look something like this (as of now anyhow):
and then you will need to install:
Sandcastle Help File Builder
Step #1
- It is important that you check installed programs and make sure you uninstall any version previous to 2.7. Apparently the installer will not update things correctly.
- The guided installer has a step that will install the Sandcastle Help File Builder for you, so you don’t have to download that yourself.
- Now run the Sandcastle installer and follow the steps. This is such a great installer I really have nothing to add at this point.
Step #2
- Step #2 involves working with the command line and I could not make it work with the instructions given in the tutorial. I continuously got an error stating that no APIs could be found. At first that was a legitimate error because the Guy class was not public, then the ToString method was not commented. However, after fixing those items I still received that error for no obvious reason. So at that point I explain how to do this through Visual Studio 2010.
This is how I did it:
1. Open Visual Studio 2010 and Create a new Class Library project called GuyProject.
2. Rename Class1 to Guy and paste in the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GuyProject
{
using System;
/// <summary>
/// A guy with a name, age and a wallet full of bucks
/// </summary>
public class Guy {
/// <summary>
/// Read-only backing field for the Name property
/// </summary>
private readonly string name;
/// <summary>
/// The name of the guy
/// </summary>
public string Name { get { return name; } }
/// <summary>
/// Read-only backing field for the Name property
/// </summary>
private readonly int age;
/// <summary>
/// The guy's age
/// </summary>
public int Age { get { return age; } }
/// <summary>
/// The number of bucks the guy has
/// </summary>
public int Cash { get; private set; }
/// <summary>
/// The constructor sets the name, age and cash
/// </summary>
/// <param name="name">The name of the guy</param>
/// <param name="age">The guy's age</param>
/// <param name="cash">The amount of cash the guy starts with</param>
public Guy(string name, int age, int cash) {
this.name = name;
this.age = age;
Cash = cash;
}
/// <summary>
/// Override of the object class ToString method.
/// </summary>
public override string ToString() {
return String.Format("{0} is {1} years old and has {2} bucks", Name, Age, Cash);
}
/// <summary>
/// Give cash from my wallet
/// </summary>
/// <param name="amount">The amount of cash to give</param>
/// <returns>The amount of cash I gave, or 0 if I don't have enough cash</returns>
public int GiveCash(int amount) {
if (amount <= Cash && amount > 0) {
Cash -= amount;
return amount;
} else {
return 0;
}
}
/// <summary>
/// Receive some cash into my wallet
/// </summary>
/// <param name="amount">Amount to receive</param>
/// <returns>The amount of cash received, or 0 if no cash was received</returns>
public int ReceiveCash(int amount) {
if (amount > 0) {
if (amount > 0) {
Cash += amount;
return amount;
}
Console.WriteLine("{0} says: {1} isn't an amount I'll take", Name, amount);
}
return 0;
}
}
}
This is basically the same code that was given in the tutorial except the Guy class wasn’t public and the public ToString member was not commented. Which are both fixed in the above version.
3. Right-click on the GuyProject and select Properties and make sure the XML Documentation File check box is checked as shown in the following screenshot.
4. Build the GuyProject project.
5. Add a new Documentation Project as shown here and name it GuyDocumentation:
6. Right-Click the Documentation folder and select “Add Documentation Sources.”
7. Navigate to the Debug/bin folder where we output our Guy.dll and Guy.xml files on the project build.
8. Select the Guy.dll file and add it. This should automatically bring along the Guy.xml file along with it. If not, then add it as well.
9. Rebuild the solution and when that has completed there should be a chm file in the new Help folder in the GuyDocumentation folder called GuyDocumentation.chm.
10. If you try to open but no content is shown then right-click and select Properties and make sure there isn’t a button showing called “Unblock.” If there is this button then click it and try to open the chm file again.
11. If all is well you should see something like this:
Later on I plan how to blog on integrating this into a TFS build, since there probably isn’t much need for each developer to continuously generate chm files on their local machine.
Have fun documenting!
No comments:
Post a Comment