Always install webapp resources under inetpub>wwwroot no matter if IIS is enabled or not

ImportantThe following article uses options that are available starting with the Professional edition and project type.

In the Files and Folders page from Advanced Installer there is the predefined IIS WWW Root folder. The path of the IIS WWW Root folder is set to the path of the PathWWWRoot of the machine where the installer is running.

However, on a machine where the Internet Information Services feature is not enabled, the path is not set correctly.

Even if the setup package will enable the IIS feature through the IIS feature activation support, the path will still not be set correctly. This is happening because the IIS feature activation is at the end of the installation process, after the files are coppied on the taget machine. If IIS feature is enabled during installation, the default path should be [WindowsVolume]\inetpub\wwwroot.

The workaround for this is to create a property-based folder in the files and folders page and assign a property to it (e.g. WWWROOT). The web app resource files should be added in the new created property-based folder.

To set the property attached to the property-based folder you need to use a custom action scheduled before the Searches stage from Wizard Dialogs Stage.

Keeping the SHIFT key pressed, drag-and-drop the custom action in tree control, under the "Install Execution Stage -> Searches" stage. This will create a copy of the action in Install Execution Stage. Set the Scheduling Option for the custom action to “Skip action in Install Execution Stage if executed in Dialogs Stage” from Advanced Execution Scenarios dialog.

For example, a PowerShell script that performs this task is the following:

param ($WinVolume)
$IsIISEnabled = get-wmiobject -query "select * from Win32_Service where name='W3svc'"
if ($IsIISEnabled)
{
	# retrieve default path from registry
	$wwwRootReg = Get-ItemProperty HKLM:\Software\Microsoft\INetStp -Name "PathWWWRoot"
	AI_SetMsiProperty WWWROOT $wwwRootReg.PathWWWRoot
}
else # IIS is not enabled
{		 # Set default to inetpub\wwwroot
   AI_SetMsiProperty WWWROOT ($WinVolume + '\inetpub\wwwroot')
}

NoteYou need to pass the -WinVolume "[WindowsVolume]\" command line in the Scipt Parameters field of the predefined Run Inline Windows PowerShell Script custom action.