At this point you have created a standard .NET installation project in Advanced Installer and ready to fill it in with your project files, configuration settings and custom installation steps.
Since installing UWS and registering your application with it requires administrative privileges, start with changing installation type to "Per machine only".
Creating application shortcut fileNow we'll take a small detour. If you follow
web application registration with UWS best practices, you will want to create a shortcut to your installed application after the installation process is over. This shortcut is a file of .url type; that URL will redirect users to your installed application, and the URL file needs to be added to your project.
Start with bringing up AI project's options..
... and then going to Project IDs tab and copying Upgrade Code to the clipboard:
Now go back to Visual Studio or whatever your IDE is and add .url file to the project, and, first, enter
Quote:[InternetShortcut]
URL=http://localhost:7756/GoToApplication.aspx/
and then paste your Upgrade Code from the prior step, comma-separated from the list of ports where your application will be listening:
Save changes and go back to AI. We'll use the URL file later. For more details on how redirection URL can be crafted, please refer to
Finding URL to your application after registration.
Adding .NET Framework 2 with Service Pack as a setup prerequisiteBefore we add UltiDev Web Server Pro to the installation, you need to add .NET Framework 2.0 with
SP1 or SP2 as a dependency. In this example, we'll add .NET Framework 2.0 SP1. Note that Service Pack 1 for .NET 2 is required for UWS to work properly, even if .NET Framework 4.0 is present on the target system.
Adding UWS as a setup prerequisiteIn Prerequisites section, add UltiDev Web Server Pro prerequisite and specify "/passive" as a "Basic UI" command line parameter to spare your end user from having to answer UWS installation questions:
Default settings of the prerequisite will ensure that latest version of UWS is downloaded from UltiDev.com web site during installation. If you don't want your installer to depend on internet connection, you can change "Setup file location" from URL to "File in package" and settings file path to "
C:\Program Files\UltiDev\Web Server\Redist\Visual Studio\UltiDev.WebServer.msi"
Make UWS prerequisite dependent on .NET Framework prereq and tell the setup bootstrapper to run your prerequisites with basic UI, i.e. with just showing progress but not asking user for input:
Specifying installation launch conditions and bootstrapper optionsLaunch conditions need to be set to reflect the fact that UWS does not support Windows before XP SP2, and that in order to run installation as elevated/administrator, to avoid custom actions popping up elevation dialog many times. And since you're most likely to distribute your work over the internet, a single-EXE installation is s must:
Adding files to the installationFilling your installer with files will begin with adding a program starter utility that we'll use to launch custom actions. We need it because MSI has trouble running programs not from the installation itself, while we'll need to run UWS application registration utility that is not a part of the installation.
Now we'll add your web application files. We'll start with creating a "WebApp" folder under "Application Folder" and insuring it has "WebApp_Dir" indetifier:
Next, let's add content to the WebApp folder by syncing it with your application folder, and excluding files that are unnecessary during run time:
Next, let's add recently-created URL shortcut file to the Programs menu by syncing IA's "Application shortcut folder" with your actual application folder, and then explicitly including only .url files in the sync:
Registering the application with UWS with Custom ActionsFinally, your application needs to be registered with UWS during installation, and unregistered during uninstallation. There are two ways to do it: one is using UWS configuration
.NET & COM API, and another, more universal and simple, is to use
UWS application registration utility. Here we demonstrate how command line utility option can be used.
We'll start with adding application unregistration step for Uninstall and failed installation Rollback situations because they are simpler than registration and are the same for all vendors and all applications.
Add "New Installed Custom Action" to "Uninstall", as shown below, and select Started.exe:
Name the uninstall step "UnregFromUWS", or whatever other name you like, set Execution Properties to "Sync execution, ignore return code", and paste following into the "Command Line" textbox:
Quote:"[ProgramFilesFolder]\UltiDev\Web Server\UWS.RegApp.exe" /u /appid=[UpgradeCode]
When your application is unregistered, its configuration is usually saved for later, in case it gets re-registered later (for example during the upgrade installation), in which case some old configuration defaults will be reused in new installation, like system-assigned listen port number.
Repeat the previous step for the Rollback custom action, with the exception of naming it something like "UnregFromUWS_RB":
Finally, we'll add the custom action that registers the application with UWS. "Command Line" value will consist of two parts:
- Static, unchanging part:
Quote:"[ProgramFilesFolder]\UltiDev\Web Server\UWS.RegApp.exe" /r /appid=[UpgradeCode] "/path=[WebApp_Dir]"
- Application-specific parameters, like listen endpoints, virtual directory, .NET Framework version, default document, etc. We suggest that listen endpoints should be configured this way:
Quote:"/url=http://*:80/,http://*:8080/,http://*:0/"
It makes application try to listen on both popular standard HTTP ports, like 80 and 8080, as well as tell UWS to register the application on any free port. Even though application registered on an arbitrary port will be listening on different ports when installed on different machines, UWS still gives you an application redirection URL wired through a well-known port 7756. We created redirection shortcut file in the beginning of this walk-through.
Quote:We also recommend that you use non-"/" virtual directory for your application, to allow for sharing popular HTTP ports, like 80.
However, if your application needs to use scripts in "/aspnet_client", like applications using Crystal Reports, then you will have to use "/" virtual directory.
Registration utility parameters are
well-documented and roughly match application settings found in
UWS Explorer management console.
In the example shown above ports 80, 8080, and a free UWS-assigned ports will be used, along with virtual directory "AIredist".
At this point you can build and run your application installation.
Starting with UWS build 15,
UWS.AppReg.exe utility started creating desktop shortcuts for registered applications. These shortcuts are app-settings-agnostic, i.e. they will work even if application gets moved to another port, gets another vdir or default doc, etc. (
Shortcuts can also be created using UWS.Configuration API's application registration methods.) UWS can create up to three shortcuts icons per application, to accommodate needs for different shortcut file locations, hostnames, icon images and start pages. See
"/SHORTCUTxxx" parameter info for more details.
Please donate at
http://www.ultidev.com/products/Donate.aspx to help us improve our products.