Want to create virtual directory inside a new website.

Topics: IIS and Web Services
Dec 6, 2010 at 9:14 AM

Hi ALL,

 I exposed a biztalk application as WCF service.

When I deploy this application using BTDF it creates a virtual directory inside d Default Website. I want to create a virtual diectory inside a new website.

I am using this script for creation of virtual directory and it create a virtual directory inside Default website.

<VDirList Include="*">
      <Vdir>BizTalkWCFExposedVdir</Vdir>
      <Physdir>..\BizTalkWCFExposedVdir</Physdir>
      <AppPool>BizTalkWCFSample</AppPool>
    </VDirList>

Thanks in advance.

Chandan

Coordinator
Dec 6, 2010 at 4:31 PM

Hi Chandan,

The Deployment Framework does not support creating a new IIS web site.  However, you can add a Target to your .btdfproj named CustomDeployTarget, and inside it use an Exec task to call appcmd.exe for IIS 7 or cscript.exe with adsutil.vbs for IIS 6 -- or a PowerShell script or a custom app that creates the website.  Your preference how you want to handle it.

Then add an MSBuild property to your .btdfproj named IISMetabasePath and pass the metabase path of your new website, like IIS://localhost/w3svc/1/Root (the Default Web Site and the default value of the property).

Thanks,
Tom

Dec 7, 2010 at 1:08 PM

Hi Tom,

I am also looking same scenario. I have tried to create  a website using below command as you suggested. 

Step2.

<IISMetabasePath Condition="'$(IISMetabasePath)' == ''">IIS://localhost/w3svc/25/Root/<websitename></IISMetabasePath> ==>Is it correct?

How to define IISMetabasePath in our .btdproj and in which section this property will define.

Could you please correct me for both website creation and ISSMetabasePath. Regards

Piyush

 <Target Name="CustomDeployTarget">
    <Exec Command="%systemroot%\system32\inetsrv\AppCmd add site /name:<websitename> /id:25 /bindings:http://localhost:17088 /physicalPath:$(MSBuildProjectDirectory)\%(VDirList.Physdir)"/>
    <Exec Command="%systemroot%\system32\inetsrv\AppCmd add app /site.name:<websitename>/path:/%(VDirList.Vdir) /physicalPath:$(MSBuildProjectDirectory)\%(VDirList.Physdir)"/>
   </Target>

Dec 7, 2010 at 1:10 PM

Hi Tom,

Sorry step1 was copied at the end. I am again posting it.

step1 

<Target Name="CustomDeployTarget">
    <Exec Command="%systemroot%\system32\inetsrv\AppCmd add site /name:<websitename> /id:25 /bindings:http://localhost:17088 /physicalPath:$(MSBuildProjectDirectory)\%(VDirList.Physdir)"/>
    <Exec Command="%systemroot%\system32\inetsrv\AppCmd add app /site.name:<websitename>/path:/%(VDirList.Vdir) /physicalPath:$(MSBuildProjectDirectory)\%(VDirList.Physdir)"/>
   </Target>

Step2.

<IISMetabasePath Condition="'$(IISMetabasePath)' == ''">IIS://localhost/w3svc/25/Root/<websitename></IISMetabasePath> ==>Is it correct?

How to define IISMetabasePath in our .btdproj and in which section this property will define.

Could you please correct me for both website creation and ISSMetabasePath. Regards

Piyush

 

Coordinator
Dec 7, 2010 at 2:30 PM

Hi Piyush,

Without actually testing it, and assuming that you have the parameters to AppCmd correct, your Step 1 looks about right.  I think you might have to change %systemroot% to $(systemroot).  FYI, the % vs. $ on the property references causes MSBuild to call the task repeatedly for each VDirList ItemGroup.

The missing step to full automation is to read in the metabase path for the newly created website and dynamically set it into the IISMetabasePath property.  You can do that in a custom MSBuild task, or there might be something included in the SdcTasks task library (from CodePlex) which is already included in the Deployment Framework.  You can look at lots of examples of custom MSBuild tasks in our source code.  There are also lots of them available online.  This would show up in the .btdfproj as one additional task called after the ones you included above.  If you did that, then you could let the regular BTDF IIS deployment proceed as it normally does (you'd have to set the property at undeploy time too with a CustomUnDeployTarget target).

On the other hand, if you statically defined the metabase path, then you would include <IISMetabasePath>IIS://localhost/w3svc/25/Root/<websitename></IISMetabasePath> in the first PropertyGroup in your .btdfproj.

I hope that gets you going in the right direction.

Thanks,
Tom