Domanda

I want to create a Application pool and a Web site in IIS. To create that I started to create a "msi" setup file. But unfortunately the setup begins with asking the Site , Virtual Directory and the App pool.

Is there a way to create the Site , Virtual directory and APP pool by a setup file?

I am using Visual Studio 2008 for the development.

Thanks in advance!

È stato utile?

Soluzione

Setup and deployment project does not have any support to create custom website or App pool under IIS. But if you really need that there are workarounds. There is .net API(Supports IIS7) wihch allows you to create Website or App pool using C#.

Programically creating Website in IIS

  1. create a console / WinForm application which creats the website and app pool(You can hardcode or let the users type in the site name during the run time).

  2. Create a setup project which will be used to execute the console application you have created. You will have to add Installer Class to your project. Within the installer class you will need to execute the console application.

Sample Code

public override void Install(IDictionary stateSaver)
{
    base.Install(stateSaver);

    Process process = new Process();

    ProcessStartInfo startInfo = new ProcessStartInfo();
    process.StartInfo = startInfo;

    startInfo.UseShellExecute = false;
    startInfo.RedirectStandardError = true;
    startInfo.FileName = "ConsoleApp.exe";
    process.Start();
}

So when you install this MSI in user's machine it will create website and app pool under IIS.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top