WIX- support multiple Instance of Web App on IIS - wix

I am using wix to create my msi installer. the installer will create a new app pool and virtual directory in the IIS to run my web app.
Right now, I am trying to have multiple instance of the web app on the same machine at the same time(either same version, or higher version).
-Is such thing supported in Wix?
-Can I dynamically create multiple app pool and virtual directory on each installation? Because at the moment the name of the appPool, and Virtual directory and destination folder are hard coded inside the Product.WXS file.

I think that you can't even perform setup multiple times, it will just try to uninstall, modify or repair your previous installation or to perform upgrade.
But regarding app pool or website name you can specify it in installation process in your feature selection dialog, to have textbox where you can write down name of website or app pool
<Control Id="WebsiteName" Type="Text" X="..." Y="..." Width="..." Height="..." Text="Website name :" Indirect="no" >
<Condition Action="hide">Installed</Condition>
</Control>
<Control Id="WebsiteName" Type="Edit" X="..." Y="..." Width="..." Height="..." Property="WEBSITENAME" Text="{50}" Indirect="no" >
<Condition Action="hide">Installed</Condition>
</Control>
Than you need to specify your property at Product.wxs
<Property Id="WEBSITENAME" Value="YourDefaultWebSiteName" Secure="yes">
<RegistrySearch Id="FindWebSiteName" Root="HKCU"
Key="SOFTWARE\YourCompany\YourProduct"
Name="WebsiteName" Type="raw"/>
</Property>
<Property Id="APPPOOL" Value="0" Secure="yes">
<RegistrySearch Id="FindWixSetupInstallation" Root="HKCU"
Key="SOFTWARE\YourCompany\YourProduct"
Name="webAppPool" Type="raw"/>
</Property>
Than you need to specify it at your settings where you create app pool and website name
<iis:WebSite Id="DefaultWebSite" Description="Default Web Site">
<iis:WebAddress Id="AllUnassigned" Port="80" />
</iis:WebSite>
<DirectoryRef Id="YourDirectory" >
<Component Id="CMP_CONFIG" Guid="{YOURGUID}" KeyPath="yes">
<iis:WebVirtualDir Id="WebsiteName" Alias="[WEBSITENAME]" Directory="YourDirectory" WebSite="DefaultWebSite">
<iis:WebApplication Id="YourApplicationApp" Name="[WEBSITENAME]" WebAppPool="[WEBSITENAME]" />
<iis:WebDirProperties Id="YourApplicationDirProp" Script="yes" Execute="yes" Read ="yes" DefaultDocuments="Default.aspx"/>
</iis:WebVirtualDir>
</Component>
</DirectoryRef>
And if you want to create shortcut to desktop
<DirectoryRef Id="DesktopFolder">
<Component Id="YourWebsiteAppDesktopShortcut" Guid="{YOURGUID}">
<RegistryValue Root="HKCU"
Key="SOFTWARE\YourCompany\YourProduct"
Name="YourWebsiteApp"
Type="integer"
Value="1"
KeyPath="yes"/>
<util:InternetShortcut Id="WebSiteDesktopShortcut"
Directory="DesktopFolder"
Name="YourWebsiteAppName"
Target="http://localhost/[WEBSITENAME]/"
Type="url" />
</Component>
</DirectoryRef>
And you just need to register all those component reference ID's in your Product.wxs

Related

Remove folder in roaming using wix3.10 installer

When uninstalling my application, I'd like to delete a folder that was added by the application.It seems like the uninstaller removes only the directories and files that were originally installed from the MSI file. How do I delete application created folder?
Following the instructions on this link:
use WixUtil extensions:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
>
then read the Folder path previously stored in the registry:
<Property Id="APPLICATIONFOLDER">
<RegistrySearch Key="SOFTWARE\$(var.Manufacturer)\$(var.SkuName)" Root="HKLM" Type="raw" Id="APPLICATIONFOLDER_REGSEARCH" Name="Path" />
</Property>
Make sure the following component is included in you installer scripts:
<DirectoryRef Id="APPLICATIONFOLDER">
<Component Id="CleanupMainApplicationFolder" Guid="*">
<RegistryValue Root="HKLM" Key="SOFTWARE\$(var.Manufacturer)\$(var.SkuName)" Name="Path" Type="string" Value="[APPLICATIONFOLDER]" KeyPath="yes" />
<!-- We need to use APPLICATIONFOLDER variable here or RemoveFolderEx
will not remove on "install". -->
<util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER" />
</Component>
</DirectoryRef>
Use the WiXUtil extension when you call both candle and light: -ext WixUtilExtension

Windows Installer not deleting all files on uninstall

I've seen some similar questions asked on here, but none of the solutions given were very clear or worked for me.
I have an installer (created with WiX) which installs certain files and folders. However, when running the installed application, this creates some folders and copies some files into it. These files and folders are not removed on uninstall.
Edited to Show Code so Far:
This INSTALLDIR property:
<Property Id="INSTALLDIR">
<RegistrySearch Id='Registry' Type='raw' Root='HKLM' Key='Software\$(var.Manufacturer)\$(var.ProductName)' Name='Location' />
</Property>
This Component which should set the install location in the registry:
<Component Id="Registry" Guid="*">
<RegistryKey Root="HKMU" Key="Software\$(var.Manufacturer)\$(var.ProductName)">
<RegistryValue Name="Location"
Type="string"
Value="[INSTALLDIR]"
Action="write"
KeyPath="yes" />
</RegistryKey>
<util:RemoveFolderEx On="uninstall" Property="INSTALLDIR" />
</Component>
This does create a record in the registry with the install location, but I'm not sure how to adapt this code to making note of the 'public' directory and removing it - I don't know where the util:RemoveFolderEx should go either (inside which component)
The clearest tutorial I've seen is this one (except that it does have an apparent error).
Replace this block:
<!--
RemoveFolderEx requires that we "remember" the path for uninstall.
Read the path value and set the APPLICATIONFOLDER property with the value.
-->
<Property Id="APPLICATIONFOLDER">
<RegistrySearch Key="SOFTWARE\$(var.Manufacturer)\$(var.SkuName)" Root="HKLM" Type="raw" Id="APPLICATIONFOLDER_REGSEARCH" Name="Path" />
</Property>
with this one:
<!--
RemoveFolderEx requires that we "remember" the path for uninstall.
Read the path value and set the FOLDERTOREMOVE property with the value.
-->
<Property Id="FOLDERTOREMOVE">
<RegistrySearch Key="SOFTWARE\$(var.Manufacturer)\$(var.SkuName)" Root="HKLM" Type="raw" Id="APPLICATIONFOLDER_REGSEARCH" Name="Path" />
</Property>
and this block:
<util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER" />
with this one:
<util:RemoveFolderEx On="uninstall" Property="FOLDERTOREMOVE" />
and you should have a working test.
The reason for using two different properties is given here and here (among with other places).
If you can derive the path from other values you may have set during installation that Windows Installer will preserve for you, such as ARPINSTALLLOCATION, then you can adjust the above implementation to get what you need without having to create your own registry keys.
Builds on B. Murri's answer:
Example: your application installs new files or folders in 'installdir/public'. These files aren't being deleted as they weren't added by the installer.
First, you need to create a registry value which will store where your public directory is installed. This is in case the user changes the install directory.
<!-- Note that the RegistryValue Value is being set to the 'public' directory ID -->
<DirectoryRef Id='INSTALLDIR'>
<Component Id="RemovePublicDir" Guid="your-guid-here">
<RegistryKey Root="HKCU" Key="Software\$(var.Manufacturer)\$(var.ProductName)">
<RegistryValue Name="Location"
Type="string"
Value="[PUBLIC]"
Action="write"
KeyPath="yes" />
</RegistryKey>
<CreateFolder Directory="PUBLIC"/>
<util:RemoveFolderEx Property="FINDPUBLICDIR" On="uninstall"/>
<RemoveFolder Id="PUBLIC" On="uninstall"/>
</Component>
</DirectoryRef>
You now need to add a property which will search for this registry value later on. Make sure your Root value above matches the one below:
<Property Id="FINDPUBLICDIR">
<RegistrySearch Id='Registry' Type='raw' Root='HKCU' Key='Software\$(var.Manufacturer)\$(var.ProductName)' Name='Location' />
</Property>
Add your manufacturer name and product name to variables, like this:
<?define Manufacturer = "My Company"?>
<?define ProductName = "Test Application"?>
Now make sure you call this Component in your Feature tag:
<Feature Id="FeatureId">
<ComponentRef Id="RemovePublicDir" />
</Feature>

Wix install location

I have a WIX setup that allows the user to select the install location. When uninstalling, I need to run a custom action that should activate a file in the install location. I tried getting the install location from session["INSTALLDIR"] but it results in the default path and not the one given by the user.
How can I reach that location?
I've done this in my own installer - the following should work.
This adds a property to retrieve the install location value from the registry.
<Property Id="INSTALLDIR">
<RegistrySearch Id='Registry' Type='raw' Root='HKCU' Key='Software\$(var.Manufacturer)\$(var.ProductName)' Name='Location' />
</Property>
This sets the install location in the registry.
<Component Id="Registry" Guid="*">
<RegistryKey Root="HKCU" Key="Software\$(var.Manufacturer)\$(var.ProductName)">
<RegistryValue Name="Location"
Type="string"
Value="[INSTALLDIR]"
Action="write"
KeyPath="yes" />
</RegistryKey>
<util:RemoveFolderEx On="uninstall" Property="INSTALLDIR" />
If you want INSTALLDIR for a later time such as uninstallation you should use Remember property pattern described in link below.
"The root issue is that the Windows Installer does not save Property values for you. That means if the user enters values in the install UI or passes them on the command-line, those values will be not be present during repair, upgrade nor uninstall."
http://robmensching.com/blog/posts/2010/5/2/the-wix-toolsets-remember-property-pattern/

Condition property failure in WIX failing entire MSI job

I am using WIX to create MSI installers for C# services. The MSI does 3 jobs :
a) Copy solution file from bin to a particular location.
b) Create a folder where the service writes it's logs.
c) install the service on the machine if it previously does not exist.
The want these to execute in the similar order. But, when the condition to check if the service is installed fails the previous step does not seem to be executing, i.e, copying and creating steps fail too.
Here is the snippet of the code.
<Directory Id="TARGETDIR" Name="SourceDir">
<!--Creating folder hierarchy for storing project solution files; reference defined in fragments-->
<Directory Id="ProgramFilesFolder" Name="PFiles"/>
<!--Creating folder hierarchy for storing logs; reference defined in fragments-->
<Directory Id="LOGS" Name="Logs"/>
</Directory>
<InstallExecuteSequence>
<LaunchConditions After='AppSearch' />
<Custom Action='CMDInstallService' Before='InstallFinalize'></Custom>
</InstallExecuteSequence>
<Property Id="MYSERVICE">
<RegistrySearch Id="SERVICE_CHECK" Root="HKLM" Name="Install" Type="raw"
Key="SYSTEM\CurrentControlSet\services\Service"/>
</Property>
<Condition Message="Service is already installed on your system">
<![CDATA[Installed OR MYSERVICE]]>
</Condition>
<CustomAction
Id='CMDInstallService' Directory='PROJECT_INSTALL' Execute='deferred' Impersonate='no'
ExeCommand='[SystemFolder]cmd.exe /K "C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe Service.exe"'
Return ='check'/>
This will not work because the files and folder are not committed before InstallFinalize. To install a service, you should use the following command:
<Component Id="Component_WinService" Directory="Directory_WindowsService" Guid="*">
<File Id="File_WindowsService" KeyPath="yes"
Source="WindowsService.exe" />
<ServiceInstall Id="ServiceInstall_WindowsService"
Type="ownProcess"
Vital="yes"
Name="My Windows service"
Description="Windows service."
Start="auto"
Account="LocalSystem"
ErrorControl="ignore"
Interactive="no"
/>
<ServiceControl Id="ServiceControl_WindowsService"
Start="install"
Stop="both"
Remove="uninstall"
Name="My Windows Service"
Wait="no"
/>
</Component>

Windows 8 search keeps showing my app name in lowercase

I've created an desktop app for Windows and a corresponding WiX installer. Let's assume my app is called "Foo". The main executable and all app references are called "Foo", with caital "F".
But Windows 8 search (the one which pops up when you enter the Start screen and begin typing) only finds the reference to my app when I type it with "f" in lowercase and shows my app name with lowercase "f" in the beginning.
Here's how I register the Start screen reference in WiX:
<RegistryValue Root="HKLM" Key="SOFTWARE\RegisteredApplications" Name="Foo" Value="SOFTWARE\Foo\Capabilities" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Foo.exe" Value="[!Foo.exe]" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Foo.exe" Name="Path" Value="[APPLICATIONFOLDER]" Type="string" />
Is there a way to tell the Windows indexing service how should it index a particular executable?
To achieve what you are asking, I would add a shortcut to the windows 8 start menu search by creating a Shortcut element. You would tie that in to a Directory element, see general example below:
<Feature Id="StartMenuShortcut" >
<Component Id="StartMenuShortcut" Guid="SOME-GUID-HERE" Directory="ApplicationProgramsFolder" >
<Shortcut Id="ApplicationStartMenuShortcut"
Name="Foo"
Target="[INSTALLFOLDER]\foo.exe"
WorkingDirectory="INSTALLFOLDER"
Icon="SomeIconFileHereIfYouHaveOne.ico"/>
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKLM" Key="Software\Microsoft\MyApplicationName" Name="installed" Type="integer" Value="1"
KeyPath="yes"/>
</Component>
</Feature>
Not only will this give you the start menu display name you desire for Foo.exe, but if Foo is ever uninstalled, this shortcut will be removed with it.
Hope this helps.