With Thanksgiving just behind me, I thought I’d share one of the software development things I’m thankful for. I’m thankful that Microsoft did away with Package And Deployment Wizard (PDW). The tools for creating setup and deployment packages in VS.Net are far more powerful and easier to work with; they may not put Wise out of business, but at least VS.Net includes a solid tool for creating installations! Customizing and extending an installation package is very straightforward, and the whole thing is completely integrated into Visual Studio .Net.
MSDN offers a lot of guidance on this subject: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vbcondeploymentscenarios.asp. This one is particularly interesting, as setting values in Web.Config is the sort of thing we end up doing a lot: http://msdn.microsoft.com/library/en-us/vsintro7/html/vxwlkwalkthroughredirectingapplicationtotargetdifferentxmlwebserviceduringinstallation.asp.
We use custom actions to attach our SQL database creation scripts to the installation. I’ll create a new assembly to contain the special logic, and then reference the assembly from the Install (and Uninstall) custom action options of our setup project. I was going to go into detail on this, but Doug Doedens has an article that covers things fairly well: http://www.c-sharpcorner.com/Code/2002/Nov/CustomUI.asp; the key is using the Context.Parameters collection in your custom installer routine (the article covers it in detail).
A few additional tips I can offer for your Installation work . . .
-The .Net Framework isn’t installed with your setup application; it’s a “launch condition” (which means your installation will not run without it), but you’ll need to take special steps to add the Framework to you install. See this link for adding DotNetFX (the .Net framework redistributable): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetdep/html/dotnetframedepguid.asp.
-Check out the command line installutil (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconInstallerUtilityInstallutilexe.asp) if you want to do “silent” installations or just to test your custom action. Installutil /i assemblyName.dll will launch your installation and InstallUtil /u will launch the uninstall.
-In the process of all these installations and uninstallations, you may encounter the following windows error message:
“The Windows Installer Service could not be accessed.
This can occur if you are running Windows in safe
mode, or if the Windows Installer is not correctly
installed. Contact your support personnel for assistance.”
This happens from time to time in our organization, usually because of an unhandled exception in an install routine. The fix is easy, go to the command line and run msiexec.exe /unregister [Press Enter]; then run msiexec.exe /regserver [Press Enter]. This will set you straight.