简体   繁体   English

动态设置INSTALLDIR

[英]Wix-Setting INSTALLDIR dynamically

I have created a web setup msi for installing a website to iis. 我已经创建了一个用于将网站安装到iis的Web设置msi。 In product.wxs I have set the directory to WWWROOT 在product.wxs中,我已将目录设置为WWWROOT

  <Directory Id='TARGETDIR' Name='SourceDir'>
  <Directory Id="IISROOT" Name='WebDir'>
     <Directory Id='INSTALLDIR' Name='MyWebSetup'></Directory>
  </Directory>
</Directory>

During installation the user can provide desired name for virtual directory. 在安装过程中,用户可以为虚拟目录提供所需的名称。 If the user is entering any other name other than 'MyWebSetup' say 'MyWebSetup1', then in the IIS a virtual directory named 'MyWebSetup1' and a directory named 'MyWebSetup' gets listed. 如果用户输入的其他名称不是“ MyWebSetup”,请说“ MyWebSetup1”,然后在IIS中列出名为“ MyWebSetup1”的虚拟目录和名为“ MyWebSetup”的目录。 Now what I want is I need to get Name='MyWebSetup' with user entered name say 'MyWebSetup1'. 现在,我要获取的Name ='MyWebSetup',用户输入的名称为'MyWebSetup1'。 I have tried using custom actions and many other to get this done, but was of no use. 我尝试使用自定义操作和许多其他操作来完成此操作,但没有用。 Please somebody can provide me with a very clear solution as I am new to Wix. 请问有人可以为我提供非常清晰的解决方案,因为我是Wix的新手。 Any helps appreciated. 任何帮助表示赞赏。 Thank you. 谢谢。

I had a similar problem but with other folders under the [INSTALLDIR], BIN and Service folders. 我有一个类似的问题,但是[INSTALLDIR],BIN和Service文件夹下有其他文件夹。

Find the IIS root path in the registry 在注册表中找到IIS根路径

 <Property Id="IISROOTPATH">
  <RegistrySearch Id="FindIISRootPath" Root="HKLM" Key="SOFTWARE\Microsoft\InetStp" Name="PathWWWRoot" Type="directory" />
</Property>

Setting the directory value with SetDirectory which runs before CostFinalize in the execute sequence 使用SetDirectory设置目录值,该目录值在执行序列中CostFinalize之前运行

<SetDirectory Id="INSTALLDIR" Sequence="execute" Value="[IISROOTPATH][VIRTUALDIR]">NOT Installed</SetDirectory>
<SetDirectory Id="SERVICEFOLDER" Sequence="execute" Value="[INSTALLDIR]\Services">NOT Installed</SetDirectory>
<SetDirectory Id="INSTALLDIRBIN" Sequence="execute" Value="[INSTALLDIR]\bin">NOT Installed</SetDirectory>

Then the directory structure 然后是目录结构

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="IISROOTPATH">
    <Directory Id="INSTALLDIR" Name="MyWebSetup">
      <Directory Id="INSTALLDIRBIN" Name="Bin">
            <!-- BIN Dicrectory -->
      </Directory>
      <Directory Id="SERVICEFOLDER" Name="Services">
            <!-- SERVICE FILES -->
      </Directory>
    </Directory>
  </Directory>
</Directory>

Here is another similar question 这是另一个类似的问题

I could solve this issue by passing the name of installdir with '.' 我可以通过将installdir的名称传递为“。”来解决此问题。 and then using setdirectory to dynamically set the name of the installdir. 然后使用setdirectory动态设置installdir的名称。 While compiling, if the name is passed as '.' 编译时,如果名称以“。”形式传递 then the compiler just ignores it for the mean time and then if we pass the installdir name later then that name will be set. 然后编译器会在此期间忽略它,然后如果稍后再传递installdir名称,则会设置该名称。

The installdir name should be passed as follows installdir名称应按以下方式传递

  <Directory Id='INSTALLDIR'
           Name='.'>

The setdirectory is passed as follows. setdirectory如下传递。 [VIRTUALDIR] is the name of virtual directory accepted from user while installation. [VIRTUALDIR]是安装时从用户接受的虚拟目录的名称。

 <SetDirectory Id="INSTALLDIR" Sequence="execute" Value="[IISROOT][VIRTUALDIR]\">NOT   Installed</SetDirectory>

Hope it helps somebody. 希望它能帮助到别人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM