Just add a custom action like this:
<CustomAction Id="GetIISWebsitesID" BinaryKey="GetIISWebsites" DllEntry="CustomAction1" Execute="immediate" Return="check"></CustomAction>
<Binary Id="GetIISWebsites" SourceFile="..\GetIISWebsites\bin\Debug\GetIISWebsites.CA.dll"/>
in your wxs file and the code for Custom Action is below:
namespace GetIISWebsites
{
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session xiSession)
{
System.Diagnostics.Debugger.Launch();
Microsoft.Deployment.WindowsInstaller.View lView = xiSession.Database.OpenView("DELETE FROM ComboBox WHERE ComboBox.Property='xxxxxxxx'");
lView.Execute();
lView = xiSession.Database.OpenView("SELECT * FROM ComboBox");
lView.Execute();
List instances = RetrieveIISWebsites();
int Counter = 0;
int Index = 0;
bool flag = false;
try
{
foreach (string str in instances)
{
Record lRecord = xiSession.Database.CreateRecord(4);
lRecord.SetString(1, "xxxxxxxx");
lRecord.SetInteger(2, Index);
lRecord.SetString(3, str);
lRecord.SetString(4, str);
lView.Modify(ViewModifyMode.InsertTemporary, lRecord);
Counter = Index;
++Index;
}
}
catch (Exception ex)
{
ex.ToString();
xiSession.Log("Exception Details: " + ex.Message);
}
lView.Close();
xiSession.Log("Closing view");
lView.Close();
return ActionResult.Success;
}
private static List RetrieveIISWebsites()
{
List result = new List();
var websites = GetSites();
foreach (Site site in websites)
{
result.Add(site.Name);
}
return result;
}
private static SiteCollection GetSites()
{
var iisManager = new ServerManager();
SiteCollection sites = iisManager.Sites;
return sites;
}
}
}
here xxxxxxxx is the property binded to Combo box.
add Microsoft.Web.Administration.dll from your C:\Program Files (x86)\WiX Toolset v3.9\bin folder.
Let me know if answered correctly or you have any doubt.