Hi everyone,
With help from the Advanced Installer team, I now have a solution which I'm hereby sharing:
1) Under "custom behavior > custom actions" I added the following "Run PowerShell inline script" (which I named "IISRootFolder"):
Script parameters:
Code: Select all
param ($WinVolume)
# Determine if IIS is installed
$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 IIsWWWRootFolder $wwwRootReg.PathWWWRoot
}
else # IIS is not installed
{
# Set default to inetpub\wwwroot
AI_SetMsiProperty IIsWWWRootFolder ($WinVolume + '\inetpub\wwwroot')
}
2) I placed the "IISRootFolder" custom action in the "Install Execution Stage" between "Searches" and "Paths Resolution", i.e.: Searches, IISRootFolder, Paths Resolutions ...
That's it!
The issues in our case was that if the IIS was not installed on the host machine during the time of installation, the website files would be incorrectly placed in the C:\Program Files (x86)\Manufacturer\Product\IIsWWWRootFolder. Then when applying the first software update, the IIS would then be present, thus causing the files to be placed in C:\inetpub\wwwroot - and in turn require reconfiguration of the IIS to point to the new folders in order for the solution's websites to work again (along with re-modification of a web.config file, but that's probably specific to our solution). Now the websites are installed in the correct location during installation, and peace has been restored.