Привязать локальные сайты IIS к выпадающему списку установки wix?

После долгой работы над созданием установщика для моего приложения с использованием http://wixtoolset.org/ и использованием 3.10v, наконец, я получил рабочий установочный файл.msi.

Но я хотел, чтобы список сайтов, которые присутствуют на сервере IIS, отображался в раскрывающемся списке во время установки, чтобы я мог выбрать существующий сайт на сервере IIS и использовать его для установки своего приложения.

Я создал элемент управления ComboBox на своей странице пользовательского интерфейса (файл.wxs) и застрял при написании настраиваемого действия, любая справка.

3 ответа

Решение

Просто добавьте пользовательское действие, как это:

  <CustomAction Id="GetIISWebsitesID" BinaryKey="GetIISWebsites" DllEntry="CustomAction1" Execute="immediate" Return="check"></CustomAction>
  <Binary Id="GetIISWebsites" SourceFile="..\GetIISWebsites\bin\Debug\GetIISWebsites.CA.dll"/>

в вашем файле wxs и код для пользовательских действий ниже:

пространство имен GetIISWebsites
{
    открытый класс CustomActions
    {
        [CustomAction]
        общедоступная статическая ActionResult CustomAction1(Session xiSession)
        {
            System.Diagnostics.Debugger.Launch();
            Microsoft.Deployment.WindowsInstaller.View lView = xiSession.Database.OpenView("УДАЛИТЬ ИЗ ComboBox, ГДЕ ComboBox.Property='xxxxxxxx'");
            lView.Execute();

            lView = xiSession.Database.OpenView("SELECT * FROM ComboBox");
            lView.Execute();
            Список экземпляров = RetrieveIISWebsites();
            int Counter = 0;
            int Index = 0;
            флаг bool = false;
            пытаться
            {
                foreach (строка str в случаях)
                {
                    Запись lRecord = xiSession.Database.CreateRecord(4);
                    lRecord.SetString(1, "xxxxxxxx");
                    lRecord.SetInteger(2, Index);
                    lRecord.SetString(3, str);
                    lRecord.SetString(4, str);
                    lView.Modify(ViewModifyMode.InsertTeorary, lRecord);
                    Счетчик = Индекс;
                    ++Index;
                }
            }
            поймать (исключение ex)
            {
                ex.ToString();
                xiSession.Log("Сведения об исключении: " + ex.Message);
            }
            lView.Close();

            xiSession.Log("Закрытие просмотра");
            lView.Close();
            return ActionResult.Success;
        }
        приватный статический список RetrieveIISWebsites()
        {
            Результат списка = новый список ();
            var website = GetSites();
            foreach (сайт на сайтах)
            {
                result.Add(site.Name);
            }

            вернуть результат;
        }
        приватная статическая SiteCollection GetSites()
        {
            var iisManager = new ServerManager();
            SiteCollection sites = iisManager.Sites;
            возврат сайтов;
        }
    }
}

здесь xxxxxxxx - это свойство, связанное с полем со списком.

добавьте файл Microsoft.Web.Administration.dll из папки C:\Program Files (x86)\WiX Toolset v3.9\bin.

Дайте мне знать, если ответили правильно, или у вас есть какие-либо сомнения.


это настраиваемая таблица с настраиваемым действием

      <CustomTable Id="tblClrList"></CustomTable>
<Fragment>
        <Binary Id="CustomActionBinary" SourceFile="..\Hemocod.Core.CustomAction\Bin\Debug\Hemocod.Core.CustomAction.CA.dll" />
        <CustomAction Id="FillComboBoxCustomAction" BinaryKey="CustomActionBinary" DllEntry="FillComboBox" Execute="immediate" Return="check"/>
</Fragment>

Это код настраиваемого действия

      
    [CustomAction]
        public ActionResult FillComboBox(Session xiSession)
        {
            MessageBox.Show("s");
            System.Diagnostics.Debugger.Launch();
            Microsoft.Deployment.WindowsInstaller.View lView = xiSession.Database.OpenView("DELETE FROM ComboBox WHERE ComboBox.Property='clrList'");
            lView.Execute();

            lView = xiSession.Database.OpenView("SELECT * FROM tblClrList");
            lView.Execute();
            List<string> 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<string> RetrieveIISWebsites()
        {
            List<string> result = new List<string>();
            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;
        }

это настраиваемое действие не вызывается при открытии диалогового окна. Скажите, пожалуйста, здесь что-то не так?

      
      This is Custom Table and custom action code i've written
------------------------------------------------------------------------------------
<CustomTable Id="tblClrList"></CustomTable>
 <Fragment>
        <Binary Id="CustomActionBinary" SourceFile="..\Hemocod.Core.CustomAction\Bin\Debug\Hemocod.Core.CustomAction.CA.dll" />
        <CustomAction Id="FillComboBoxCustomAction" BinaryKey="CustomActionBinary" DllEntry="FillComboBox" Execute="immediate" Return="check"/>
</Fragment>
------------------------------------------------------------------------------------
[CustomAction]
        public ActionResult FillComboBox(Session xiSession)
        { 
            System.Diagnostics.Debugger.Launch();
            Microsoft.Deployment.WindowsInstaller.View lView = xiSession.Database.OpenView("DELETE FROM ComboBox WHERE ComboBox.Property='clrList'");
            lView.Execute();

            lView = xiSession.Database.OpenView("SELECT * FROM tblClrList");
            lView.Execute();
            List<string> 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<string> RetrieveIISWebsites()
        {
            List<string> result = new List<string>();
            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;
        } 

Этот настраиваемый метод не вызывается сам по себе и не связывает мои раскрывающиеся данные, не могли бы вы помочь мне в этом

Другие вопросы по тегам