1

I am using VSTS 2008 + C# + .Net 3.5 + IIS 7.0. I want to using appcmd to add a new web site, my scenario is like this.

  1. All my web site files are under folder c:\template;
  2. I want to add my new web site as a virtual directory under default web site, the virtual directory is called "testsite1";
  3. I want to use the default application pool (or the application pool which default web site is using).

I have stuied appcmd for quite some time, but cannot figure out. Maybe either I am too stupid or because IIS 7.0/appcmd is new, help information is limited. :-)

Appreciate if anyone could let me know how to complete my deployment task using appcmd?

thanks in advance, George

George2
  • 1,137
  • 6
  • 22
  • 41
  • I had the same issue and posted it on the MSDN forums (with no reply yet, but I will cross it here should an answer show up there). It seems like one could work out issues like this on their own if only there was explicit documentation about the funky square-bracket syntax they use for adding new elements. – patridge Jul 19 '10 at 19:01

1 Answers1

1

If you're trying to do this from code, I would recommend Microsoft.Web.Administration instead of appcmd. However, if you're doing it from the command line then appcmd is what you need.

Additionally if you have access to the server, why are you using vdirs for sites instead of full sites? You may find that full sites are cleaner. It depends on your situation, of course.

To do it with appcmd, it would be something like this:

  • First, make sure that the folder is created. You can do that with the old command line 'md'
  • Then create the 'application'. It will use the default app pool, not the one of its parent. It's a bit more work to figure out the app pool of the parent first. It would be something like:

    appcmd add app /site.name:"sitename" /path:/foldername

  • Then create the 'vdir'.

    appcmd add vdir /app.name:"sitename/foldername" /path:/ /physicalpath:c:\inetpub\wwwroot\foldername

Scott Forsyth
  • 16,339
  • 3
  • 36
  • 55
  • Is there a way to do this as described in the OP, though? I have a situation where I am working to automate the creation of a site already in use that does that very situation (the appcmd equivalent right-clicking a site subdirectory and saying "Convert to Application" within IIS). – patridge Jul 19 '10 at 19:16
  • Hi Patridge. What's OP? – Scott Forsyth Jul 27 '10 at 13:47