在wix安装的下拉列表中绑定IIS本地网站?
使用 http://wixtoolset.org/ 为我的应用程序创建安装程序后,我很长时间使用3.10v,最后我得到了工作的.msi安装程序文件。
After working long for the creating the installer for my application using http://wixtoolset.org/ and i am using 3.10v,finally i got the working .msi installer file.
但是我希望IIS服务器中存在的网站列表在下拉列表中显示安装,以便我可以从IIS服务器中选择现有的网站并使用它来安装我的应用程序。
But i wanted the list of websites that are present in IIS server to be display in the dropdown list during installation, so that i can select the existing website from the IIS server and use that to install my application.
我在我的UI页面创建了一个ComboBox控件(.wxs文件),并坚持写自定义动作,任何帮助非常感谢!!
I created a ComboBox Control in my UI page (.wxs file), and stuck at writing the custom action, any Help Greatly appreciate!!
只需添加这样的自定义动作:
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;
}
}
}
此处xxxxxxxx是绑定到组合框的属性。
here xxxxxxxx is the property binded to Combo box.
从C:\Program Files(x86)\ WiX Toolset v3.9 \ bin文件夹中添加Microsoft.Web.Administration.dll。
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.