Doing this is a little harder than you’d think, there’s a few gotchas, so this post aims to step you through it.
Add a new project to your solution, under ‘Other Project Types’, ‘Setup and Deployment’ choose ‘Setup Project’.

You’ll see a view like this, delete ‘Users Desktop’, ‘User Programs Menu’

Right click on Application folder and go to add > project output. Choose the Addin project.

Right click on application folder again, go to properties and change the DefaultLocation to be:
[ProgramFiles64Folder][Manufacturer]\[ProductName]
This is so that it will always be in a consistent install location, rather than program files (x86).
Now, we don’t want to distribute RevitAPI and RevitAPIUI dlls, so in the solution explorer, expand detected dependencies and right click on those and click exclude.

Click on the installer project, then click the properties tab, and set the ‘Manufacturer’ and ‘ProductName’ to match your company/addin name. Also, while you are here, change the ‘TargetPlatform’ to X64. Unfortunately with these types of installers you need a separate install for X86 and X64, but I think most of you will be building API addins for X64 systems, as Revit generally needs at least 4gb of RAM, and if you are enough of a power user to be installing add-ins, you are going to be running a 64bit operating system I’m sure. But keep in mind that it may vary for you.
We need to create a .addin manifest file that points to the program files folder as follows, make sure you generate a new GUID.
<RevitAddIns>
<AddIn Type="Command">
<Text>My Revit Util</Text>
<Assembly>C:\Program Files\COMPANY NAME\PRODUCT NAME\Addin.dll</Assembly>
<AddInId>18520534-3ee1-473e-ae97-a68dfbda3754</AddInId>
<FullClassName>MyRevitUtil.Command</FullClassName>
<VendorId>COMP </VendorId>
<VendorDescription>MY COMPANY </VendorDescription>
</AddIn>
</RevitAddIns>
In The primary output screen, add a new custom folder, called Autodesk Addins. Right click on it and go to properties and set the DefaultLocation to
[CommonAppDataFolder]\Autodesk\Revit\Addins\2012
and Property to AUTODESKADDINS
This will install it for all users. Right click in the middle panel and go to add file, and choose your manifest.

At this point you’re almost done, there’s just a couple of .NET settings to tweak. First of all, we don’t need to bundle an installer for .NET framework as Revit installs it by default, so right click on your installer project, go to properties and hit prerequisites

Then untick the first checkbox

Finally, right click on your project, click View > Launch Conditions, click .NET framework and change it to .NET Framework 4 (or lower if you are in Revit 2011 mode still).

Now you are done, you can right click your project and go to Build and your .msi installer will be output.