Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在WiX IIS安装程序中将引用目录的名称替换为虚拟目录的名称_Iis_Wix - Fatal编程技术网

在WiX IIS安装程序中将引用目录的名称替换为虚拟目录的名称

在WiX IIS安装程序中将引用目录的名称替换为虚拟目录的名称,iis,wix,Iis,Wix,我用wix为一个网站创建了一个安装程序。在安装过程中,用户接受虚拟目录的名称。如果用户提供的名称不同于引用目录的名称,则虚拟目录和引用目录都将在IIS中列出,这是我不希望看到的。如何通过在安装过程中用虚拟目录的用户给定名称覆盖引用目录的名称来避免这种情况。感谢所有帮助。下面是我使用的主wxs文件的代码 多谢各位 <?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wi

我用wix为一个网站创建了一个安装程序。在安装过程中,用户接受虚拟目录的名称。如果用户提供的名称不同于引用目录的名称,则虚拟目录和引用目录都将在IIS中列出,这是我不希望看到的。如何通过在安装过程中用虚拟目录的用户给定名称覆盖引用目录的名称来避免这种情况。感谢所有帮助。下面是我使用的主wxs文件的代码

多谢各位

 <?xml version="1.0" encoding="UTF-8"?>
 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
  xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
 <!-- The upgrade GUID ** DO NOT CHANGE!! **-->
 <?define ProductUpgradeCode="da7c5352-634c-408c-ad5c-5ff806106378"?>
  <!-- The product version. -->
 <?define InstallVersion="1.0.0.0"?>
 <?define DirName="C:\inetpub\wwwroot"?>
  <!-- It's aways a major upgrade here. -->
  <Product Id="*"
       Name="Basic Web App Install Example"
       Language="1033"
       Version="$(var.InstallVersion)"
       Manufacturer="John Robbins/Wintellect"
       UpgradeCode="$(var.ProductUpgradeCode)">
   <Package Id="*"
           Description="A simple web site installation"
         Comments="Just showing how it works."
         Manufacturer="John Robbins/Wintellect"
         InstallerVersion="300"
         Languages="1033"
         Compressed="yes"
         SummaryCodepage="1252"
         InstallPrivileges="elevated"/>


  <!-- Major upgrade checks. -->
  <MajorUpgrade Schedule="afterInstallInitialize"
              DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit."/>

  <UIRef Id="WixUI_InstallWeb" />
  <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />    
  <Property Id="_BrowseProperty" Value="INSTALLDIR" />
  <Property Id="WIXUI_VIRTUALDIR" Value="VIRTUALDIR" />
  <Property Id="VIRTUALDIR"><![CDATA[Staffbank]]></Property>    
  <!-- Check to see if IIS is installed. It it's not, error out. -->    
  <Property Id="IIS_MAJOR_VERSION">
  <RegistrySearch Id="CheckIISVersion" Root="HKLM" Key="SOFTWARE\Microsoft\InetStp" Name="MajorVersion" Type="raw" />
  </Property>

  <Condition Message="IIS must be installed">
  Installed OR IIS_MAJOR_VERSION
  </Condition>

  <!-- Go find the IIS root directory from the registry. On most machines
     that defaults to C:\inetpub\wwwroot. This will be the directory we 
     install into. -->
<Property Id="IISROOT">
  <RegistrySearch Id="IISROOT"
                  Type="directory"
                  Root="HKLM"
                  Key="Software\Microsoft\InetStp"
                  Name="PathWWWRoot" />
   </Property>

    <Condition Message="IIS does not appear to be installed correctly, the root directory is not set.">
  Installed OR IISROOT
    </Condition>

   <!-- Describe the media source (you always have to have this) -->
   < Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

   <!-- The root of life for any installer. -->
   <Directory Id='TARGETDIR' Name='SourceDir'>
    <!-- Install into the ISS root directory we found earlier. -->
    <Directory Id="IISROOT" Name='WebDir'>
    <!-- Here's this installers install location. -->
    <Directory Id='INSTALLDIR' Name='Staffbank'></Directory>
    </Directory>
  </Directory>
   <DirectoryRef Id='INSTALLDIR' >          
      <!--Creating the webpool for our site-->

      <Component Id="MyWebAppPoolCmp" Guid="{98da0c81-999d-4de8-bb8e-4e9a61ae31e5}" KeyPath="yes" Permanent="yes">            
        <iis:WebAppPool Id="MyWebAppPool" Name="ASP.NET v4.0"></iis:WebAppPool>
      </Component>
      <!-- The component to define the Virtual Directory.-->
      <Component Id="WebVirtualDirComponent"
                 Guid="D814F88F-6E0C-4365-A411-2F9807522C3D">
        <!-- The virtual directory we are installing. -->
        <!-- The Alias attribute is the name thata will be put into IIS.-->
        <!-- The Directory attribute is the "Physical Path" property in
              IIS and needs to tie to an ID specified in the setup. -->
        <!-- The WebSite attribute ties to a <WebSite> element in the 
             setup file. As this is an example of installing into the 
             "Default Web Site" that element is not under a component.-->
        <iis:WebVirtualDir Id="VDir"
                           Alias="[VIRTUALDIR]"
                           Directory="INSTALLDIR"
                           WebSite="DefaultWebSite">
          <!-- Turn the Virtual Directory into a web application. -->
          <iis:WebApplication Id="TestWebApplication"
                              Name="[VIRTUALDIR]" WebAppPool ="MyWebAppPool" />
        </iis:WebVirtualDir>
        <!-- This is pretty important. If the CreateFolder isn't there the
             WebVirtualDir won't get created as there's no files in this
             component.
             http://www.mail-archive.com/wix-users@lists.sourceforge.net/msg03483.html -->
        <CreateFolder/>
      </Component>
    </DirectoryRef>

  <!-- Because I want to show an example of installing a web site under an 
     existing web site, "Default Web Site", you have to keep this element
     outside of a component. See the WiX documentation: 
     http://wix.sourceforge.net/manual-wix3/iis_xsd_website.htm. 
     Basically, outside a component means it's a locator/searching. Inside
     a component means it's a creator. -->
  <iis:WebSite Id='DefaultWebSite'
             Description='Default Web Site'                 
             Directory='INSTALLDIR'>
    <!-- This element has to be here or WiX does not compile. It's ignored
       in this case. -->
    <iis:WebAddress Id="AllUnassigned" Port="80" />
  </iis:WebSite>



<Feature Id='TestProductFeature' Title='Wix File Product Feature' Level='1'>
  <ComponentRef Id="MyWebAppPoolCmp"/>
  <ComponentRef Id='WebVirtualDirComponent' />
  <ComponentGroupRef Id='BASICWEBAPPFILES'/>
   </Feature>
  </Product>
 </Wix>

已安装或IIS\u主要\u版本
已安装或IISROOT
我可以通过将installdir的名称与“.”一起传递,然后使用setdirectory动态设置installdir的名称来解决这个问题。在编译时,如果名称以“.”的形式传递,那么编译器将同时忽略它,如果稍后传递installdir名称,那么将设置该名称

应按如下方式传递installdir名称

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

setdirectory的传递方式如下所示。[VIRTUALDIR]是安装时从用户处接受的虚拟目录的名称

 <SetDirectory Id="INSTALLDIR" Sequence="execute" Value="[IISROOT][VIRTUALDIR]\">NOT   Installed</SetDirectory>`
未安装`
希望它能帮助别人