Try to create a Virtual Directory in a subdirectory

Topics: IIS and Web Services, Server Deployment
Apr 17, 2014 at 2:32 PM
Hi everybody,

I'm trying to deploy a new web service named Test.svc that would not be at the Default Web Site Root level but in sub-directories (that need to be created).

The wanted structure would be :

Default Web Site
 - Employees 
     - Level1
         - MySvc
I don't know how to do this.

In my btdf file, I tried to set the whole path in Vdir but that's not working

<VDirList Include="*">
Then I tried to precise the metabase path like this :
<VDirList Include="*">
But this MetadabasePath seems to be invalid.

Do you have any idea of what doing this ?

Thanks in advance !!

Apr 18, 2014 at 4:48 AM
Hi, this is only supported in v6.0 which is not yet available. Today, you have a couple of options -- create the virtual directory outside of the BTDF MSI, whether manually in IIS Manager or with another script, OR set IncludeVirtualDirectories to false and build your own IIS configuration inside a custom target in your .btdfproj. You didn't say what version of IIS, but with IIS 7 you can use appcmd.exe to do most anything. There is already an MSBuild property holding the path to appcmd.exe -- $(AppCmd). You can use the Exec task to run the commands.

Jun 3, 2014 at 4:01 PM
Edited Jun 3, 2014 at 4:40 PM

Many thanks for your answer and sorry for the delay. I was waiting to test your suggestion (doing a custom target) but was on another subject until now.

I have successfully created a target to deploy one web app in a virtual directory with a folder hierarchy, but have an issue when trying to deploy several web app in the same deployment project.

Here is a part of my .btdfproj file :

    <VDir Include="*">
    <WebAppList Include="*">
    <WebAppList Include="*">
And the .targets :
  <Target Name="CreateWebApp">
       <CreateItem Include="%(WebAppList.WebAppLocation)">
      <Output TaskParameter="Include" ItemName="WebAppPhysicalLocation" />
     <Exec Command="&quot;$(AppCmd)&quot; add app /;$(VDirRootCreation)&quot; /path:%(WebAppList.WebAppPath) /physicalPath:@(WebAppPhysicalLocation->'%(FullPath)')"/>
I don't have BTDF error, but an issue in IIS (web app don't appears (given path's format is not valid).
I think it is because the CreateItem stores the two locations concatenated and not one after the other.

In fact, I don't really know how to handle a collection of values and didn't found a doc on this.
Maybe you have a clue?
Else, I think I will do it with a powershell script.

Can I also ask you the meaning of Include="*" ? (it was required but I don't know why!)

Jun 4, 2014 at 8:02 AM
Hi again,

I finally found an answer just after posting.

I removed the CreateItem and get the path like this, with the $(MSBuildProjectDirectory) property
 <Exec Command="&quot;$(AppCmd)&quot; add app /;$(VDirRootCreation)&quot; /path:%(WebAppList.WebAppPath) /physicalPath:$(MSBuildProjectDirectory)\%(WebAppList.WebAppLocation)"/>
It works :-)
Jun 5, 2014 at 4:36 AM
Great, thanks. The Include="" is there because Include is required, so I made it "". It doesn't do anything.