1

I am trying to create a basic WiX installer for my web API application, as a part of installer i would like it to create web directory and web application for the project. I have the below code with is doing everything except, it doesn't create the web application. I would like the iss folder structure to look like

IIS desired structure

This is my code:

   <Fragment>
    <SetDirectory Id="WINDOWSVOLUME" Value="[WindowsVolume]"/> 
      <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="WINDOWSVOLUME">
          <Directory Id="DiagonalFolder" Name="Diagonal">
            <Directory Id="ServicesFolder" Name="WebServices">
              <Directory Id="LocationServicesFolder" Name="LocationServices">
                  <!-- Since the installation directory is not 'Program Files', MUST use ComponentGuidGenerationSeed which  MUST NEVER CHANGE for life of Product -->
                  <Directory Id="INSTALLFOLDER" Name="Bin" ComponentGuidGenerationSeed="PUT-GUID-HERE">
                  </Directory>
              </Directory>
            </Directory>
          </Directory>
        </Directory>
      </Directory>  
   </Fragment>

  <Fragment>
    <ComponentGroup Id="IISComponentGroup" Directory="TARGETDIR">
      <!--The component to define the Virtual Directory-->
      <Component Id="IIS.Component" Guid="*" KeyPath="yes">

        <iis:WebVirtualDir Id="VDir" Alias="api" Directory="ServicesFolder" WebSite="DefaultWebSite">
          <!--Turn the Virtual Directory into a web application-->
          <iis:WebApplication Id="WebApplication" Name="ls" WebAppPool="TheAppPool">
          </iis:WebApplication>
        </iis:WebVirtualDir>
        <iis:WebAppPool Id="TheAppPool" Name="DefaultAppPool" ></iis:WebAppPool>
      <CreateFolder/>
      </Component>
      </ComponentGroup>


    <iis:WebSite Id="DefaultWebSite" Description="Default Web Site" Directory="TARGETDIR">
      <!-- This element has to be here or WiX does not compile. It’s ignored in this case.-->      
      <iis:WebAddress Id="AllUnassigned" IP="*" Port="8080" />
    </iis:WebSite>   
  </Fragment>

This creates the web application folder named 'api' instead of web dir and does not create web application with name 'ls'. it should look like localhost/api/ls

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
RWD
  • 11
  • 2
  • 1
    I don't have a proper IIS server available to test this right now, but [**maybe have a look at this github sample from Rainer Stropek**](https://github.com/rstropek/Samples/blob/master/WiXSamples/WebInstaller/Setup/Product.wxs) to see if you find some pointers. Towards bottom. [**Other WiX samples**](https://github.com/rstropek/Samples/tree/master/WiXSamples). – Stein Åsmul Jul 24 '18 at 02:11

0 Answers0