Wix & Burn - Install IIS if not yet installed

Nagy Vilmos picture Nagy Vilmos · Jun 26, 2014 · Viewed 8k times · Source

I've a project using IIS, and I want to create an installer for it with Wix. I've created the .msi installer for the app successfully, and I'm creating a Bundle installer for it, which will install the prerequisites and after that my application.

Here's the Bundle's code:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
  xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
  xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
  <Bundle Name="Bootstrapper" Version="1.0.0.0" Manufacturer="VilmosNagy" UpgradeCode="844c755f-f02b-4dd3-8b9c-af2498f3128c">
    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
    <Chain>
      <PackageGroupRef Id="NetFx45Web"/>
      <PackageGroupRef Id="SQLServerExpress"/>
      <!-- <MsiPackage SourceFile="path\to\your.msi" /> -->
    </Chain>
  </Bundle>
</Wix>

My question is, how can I install (or enable?) the IIS, IF not installed?

Thanks!

Answer

Nagy Vilmos picture Nagy Vilmos · Jul 1, 2014

Based on Harbinder Singh's answer, here's my solution:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
    <Bundle Name="Bootstrapper" Version="1.0.0.0" Manufacturer="VilmosNagy" UpgradeCode="844c755f-f02b-4dd3-8b9c-af2498f3128c">
        <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />

    <Chain>
      <PackageGroupRef Id="InstallIIS"/>
    </Chain>
    </Bundle>
  <Fragment>    
    <PackageGroup Id="InstallIIS">
      <ExePackage
                  Id="IIS_part0"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-WebServerRole"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-WebServerRole"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part1"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-WebServer"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-WebServer"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part2"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-CommonHttpFeatures"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-CommonHttpFeatures"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part3"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-StaticContent"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-StaticContent"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part4"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-DefaultDocument"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-DefaultDocument"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part5"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-DirectoryBrowsing"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-DirectoryBrowsing"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part6"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-HttpErrors"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-HttpErrors"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part7"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-HttpRedirect"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-HttpRedirect"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part8"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-ApplicationDevelopment"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part10"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-NetFxExtensibility"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-NetFxExtensibility"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part12"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-ISAPIExtensions"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ISAPIExtensions"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part11"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-ASP"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ASP"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part13"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-ISAPIFilter"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ISAPIFilter"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part9"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-ASPNET"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ASPNET"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part14"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-HealthAndDiagnostics"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-HealthAndDiagnostics"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part15"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-HttpLogging"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-HttpLogging"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part16"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-LoggingLibraries"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-LoggingLibraries"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part17"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-RequestMonitor"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-RequestMonitor"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part18"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-HttpTracing"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-HttpTracing"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part19"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-CustomLogging"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-CustomLogging"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part20"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-Security"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-Security"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part21"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-WindowsAuthentication"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-WindowsAuthentication"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part22"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-RequestFiltering"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-RequestFiltering"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part23"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-IPSecurity"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-IPSecurity"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part24"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-Performance"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-Performance"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part25"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-HttpCompressionStatic"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-HttpCompressionStatic"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part26"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-WebServerManagementTools"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-WebServerManagementTools"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part27"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-ManagementConsole"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ManagementConsole"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part28"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-ManagementScriptingTools"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ManagementScriptingTools"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part29"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: IIS-ManagementService"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ManagementService"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part30"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: WAS-WindowsActivationService"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:WAS-WindowsActivationService"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part31"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: WAS-ProcessModel"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:WAS-ProcessModel"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part32"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: WAS-NetFxEnvironment"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:WAS-NetFxEnvironment"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part33"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: WAS-ConfigurationAPI"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:WAS-ConfigurationAPI"
                  >
      </ExePackage>
      <ExePackage
                  Id="IIS_part34"
                  SourceFile="run.bat"
                  DisplayName="Installing IIS: NetFx3"
                  InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:NetFx3"
                  >
      </ExePackage>
    </PackageGroup>
  </Fragment>
</Wix>

The run.bat file is a simple text file, containing %*.

This solution only works on Windows 7, or higher, 'cause the dism.exe is not part of the Windows before version 7.