Try to create a Virtual Directory in a subdirectory

Topics: IIS and Web Services, Server Deployment
Apr 17, 2014 at 3: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
             -Web.Config
             -Test.svc
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="*">
  <Vdir>/Employees/Level1/MySvc</Vdir>
  <Physdir>..\ws\Test\</Physdir>
  <AppPool>MyAppPool</AppPool>
  <AppPoolNetVersion>v2.0</AppPoolNetVersion>
</VDirList>
Then I tried to precise the metabase path like this :
<IISMetabasePath>IIS://localhost/w3svc/1/Root/Employees/Level1</IISMetabasePath>
<VDirList Include="*">
  <Vdir>MySvc</Vdir>
  <Physdir>..\ws\Test\</Physdir>
  <AppPool>MyAppPool</AppPool>
  <AppPoolNetVersion>v2.0</AppPoolNetVersion>
</VDirList>
But this MetadabasePath seems to be invalid.

Do you have any idea of what doing this ?

Thanks in advance !!

Regards,
RCEHA.
Coordinator
Apr 18, 2014 at 5: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.

Thanks,
Tom4
Jun 3, 2014 at 5:01 PM
Edited Jun 3, 2014 at 5:40 PM
Hi,

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 :

<ItemGroup>
    <VDir Include="*">
      <VDirName>Employees</VDirName>
      <VDirLocation>..\WS\Employees</VDirLocation>
    </VDir>
    <WebAppList Include="*">
      <WebAppPath>/Employees/Level1/MySvc</WebAppPath>
      <WebAppLocation>..\WS\Employees\Level1\MySvc</WebAppLocation>
      <AppPool>MyAppPool</AppPool>
    </WebAppList>
    <WebAppList Include="*">
      <WebAppPath>/Employees/Level1/MySecondarySvc</WebAppPath>
      <WebAppLocation>..\WS\Employees\Level1\MySecondarySvc</WebAppLocation>
      <AppPool>MyAppPool</AppPool>
    </WebAppList>
  </ItemGroup>
And the .targets :
  <Target Name="CreateWebApp">
       <CreateItem Include="%(WebAppList.WebAppLocation)">
      <Output TaskParameter="Include" ItemName="WebAppPhysicalLocation" />
    </CreateItem>
    
     <Exec Command="&quot;$(AppCmd)&quot; add app /site.name:&quot;$(VDirRootCreation)&quot; /path:%(WebAppList.WebAppPath) /physicalPath:@(WebAppPhysicalLocation->'%(FullPath)')"/>
  </Target>
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!)

Thanks!
Jun 4, 2014 at 9: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 /site.name:&quot;$(VDirRootCreation)&quot; /path:%(WebAppList.WebAppPath) /physicalPath:$(MSBuildProjectDirectory)\%(WebAppList.WebAppLocation)"/>
It works :-)
Coordinator
Jun 5, 2014 at 5:36 AM
Great, thanks. The Include="" is there because Include is required, so I made it "". It doesn't do anything.

Thanks,
Tom