views:

914

answers:

9

I need to deploy a web application on several laptops (although it is a web application, it is intended to run via localhost only - thus the need to deploy on several different machines).

Normally I would go to IIS and right click a directory to create a web application, but I would very much like to automate this leg of the installation. Can it be done?

edit: My question, clearly, isn't very clear.

I want to use IIS, but I want to create the web application automatically without opening the IIS Microsoft Management Console (MMC).

+1  A: 

To implement a minimal web server you can use HTTP.SYS (the core component of IIS deployed with Windows XP SP2 or higher). In .NET this can be done e.g. by using the HttpListener class in the System.Net namespace.

Regards, tamberg

tamberg
+2  A: 

You can look inside the Cassini Sample Web Server (comes with source):

The ASP.NET Cassini Web Server Sample is a sample web server written using the Microsoft® .NET® Framework, and demonstrates hosting ASP.NET using the ASP.NET hosting APIs (System.Web.Hosting).

gimel
+1  A: 

You could also try Mono http://mono-project.com/

It is for Linux, Mac OS X and Windows.

They have xsp a web server for .net applications.

There is documentation about that in

http://www.mono-project.com/ASP.NET

Good luck,

Sebas
+4  A: 

You're really asking two different questions. First, why reinvent the wheel? In all likelihood, the laptops are already capable of running IIS - it's available on all "modern" Windows versions with the possible exception of Vista Home. Second, a VS.NET installer can easily target and automate an install to IIS. If you use Wix or some other third party installer it will require more manual work but can still be done.

Edit: In re-reading your question, that sounds like what you're really asking - you already knew IIS was available on the target computers, but just didn't want to manually install on each computer. Correct? In that case, definitely look at the VS.NET setup project - they have a built-in target for IIS deployment.

GalacticCowboy
YES that is what I am talking about, I just edited the question :D Thx
DrG
+1 for reading the question. I was thinking "Mono" at first as well, but as it turns out the title has not much to do with the text...
Tomalak
actually i think no one read the word "automate" in the question title .....
DrG
I think that's because it was not in there to begin with. :-) I changed the title to what it is right now.
Tomalak
hahaha. good one!
DrG
+1  A: 

Create a new Visual Studio project of type "Setup and Deployment", and use the "Web Setup" type.

This will create an .msi installer that will automatically create the web app for you within IIS.

You will then also get the ability to perform network installs, so if you have the right permissions you could manage this centrally.

A: 

Have look at this post. It explains how to start Cassini web server from the command line and add it as a shell extension.

EDIT: CarlosAg's blog has some great posts about IIS administration throw PowerShell and managed code.

Eduardo Campañó
+1  A: 

You can create a virtual directory without using the MMC console using the WebDirectoryCreate task available inside the project msbuildtasks

labilbe
+4  A: 

I can sugest you to take a look at this link if you are deploying on IIS6 or at this one if it is IIS7(I could recommend Mike Volodarsky's blog for any info on IIS7 in general). It should be quite simple for you to write some batch file to automate a site creation. Example:

  • IIS6 : iisweb /create C:\Rome "My Vacations" /d www.reskit.com /dontstart
  • IIS7 : %windir%\system32\inetsrv\AppCmd ADD SITE /name:MyNewSite /bindings:http/*:81: /physicalPath:c:\inetpub\mynewsite
exactly what I needed, let's hope I can make it work :D
DrG
+2  A: 

You could use the system.DirectoryServices class e.g.

http://www.gafvert.info/iis/article/cs_create_website_iis6.htm

ca8msm