7

I created a WiX package for my website, and it works fine, except that my newly created website doesn't start after installation. That's because my website is registered to use *:80. IIS by default has a website setup with the same binding.

Is there a way to remove default website (or at least stop it) before creating my new website binding? I can't seem to find any information for this on the internet, but it seems like a common problem.

Ilya Volodin
  • 10,929
  • 2
  • 45
  • 48

2 Answers2

1

I found how to do this, I thought I'd put an answer for any weary travelers:

<CustomAction Id="RegisterCommand"
              Property="RegisterPowerShellProperty"
                                Execute="immediate"
                                Value="&quot;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&quot; -ExecutionPolicy ByPass -NoLog -InputFormat None -NoProfile -command &quot;Remove-IISSite -Name 'Default Web Site' -Confirm:$false&quot;"/>
<CustomAction Id="RegisterPowerShellProperty"
              BinaryKey="WixCA"
              DllEntry="CAQuietExec64"
              Execute="deferred"
              Return="check"
              Impersonate="no" />

<InstallExecuteSequence>
        <Custom Action="RegisterCommand" After="CostFinalize">NOT Installed</Custom>
       <Custom Action="RegisterPowerShellProperty" After="InstallFiles">NOT  Installed</Custom>     
</InstallExecuteSequence>

My answer was based off this article: here

JohnChris
  • 1,360
  • 15
  • 29
0

What you're trying to do is considered a very bad taste in the world of software installation. The installation program must never mess up the target system. Most likely there's some website up and running, which will become unresponsive after your installation program completes.

You should always assume that before your installation program starts, the target system is in some known stable state. Disregarding of how your install ends up, you should leave the system in stable known state. This is why there's a concept of rollback actions, which are responsible for rolling the actions back in case we need to roll back the entire installation transaction.

I would recommend you to revise your installation program regarding that IIS behavior. For instance, always create a new IIS website, with the unique name. You can even create a separate application pool for it to make it truly isolated. It will be much easier to uninstall the software then - you just let the Windows Installer to do its job uninstalling what it has installed.

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
  • 1
    This is an internal only installation for one-touch deployment of the website I'm working on, so I'm ok with messing up existing and running websites (I actually want them all removed). Separate application pool and unique name will not work, since two websites can't simultaneously run on the same port and same IP address without the use of host headers. – Ilya Volodin Mar 21 '14 at 01:08