Unable to use a variable name inside IISMetabasePath

Topics: IIS and Web Services
Jul 22, 2013 at 9:13 AM
Edited Jul 22, 2013 at 9:14 AM
Hi Tom,
I am using Biztalk 2013 along with BTDF 5_1 Beta2 .
I want to deploy my webservice in a website other than default website. I looked at other blogs and tried this:

<IISMetabasePath>IIS://localhost/w3svc/${IISWebSiteID}/Root</IISMetabasePath>

When I hard code the IISWebsiteID value it works fine .But when I pass it as variable name I get error: MSB4018: The "CreateVirtualDirectory" task failed unexpectedly . Specified file path cannot be found.

I am already setting this variable in settingsfilegenerator and in my btdfproj file ,
<PropsFromEnvSettings Include="SsoAppUserGroup;SsoAppAdminGroup;IISWebSiteID" />

Since we have different environments where ID of website will differ based on environments I cannot hard code it . Could you please help me with this ?
Coordinator
Jul 22, 2013 at 5:01 PM
Hi,

You're seeing this because of MSBuild order of evaluation.

You can replace IISWebSiteID with IISMetabasePath, and just put the entire IIS://<etc> URI into the settings spreadsheet for each environment. There's no need to have another property in addition to IISMetabasePath unless you really want to split them up.

That said, if directly using IISMetabasePath doesn't help then you'll need to set it at runtime -- and then you're probably better off having the separate property as you do now. You can add a target:
<SetIISMetabasePath BeforeTargets="DeployVirtualDirectory;UndeployVDirs">
    <CreateProperty Value="IIS://localhost/w3svc/${IISWebSiteID}/Root">
      <Output TaskParameter="Value" PropertyName="IISMetabasePath" />
    </CreateProperty>
</SetIISMetabasePath>
Thanks,
Tom
Jul 23, 2013 at 10:12 AM
Hi Tom,
It still didnot work me.I tried both ways.

I did this for second method,
<Target Name="SetIISMetabasePath" BeforeTargets="DeployVirtualDirectory;UndeployVDirs">
<CreateProperty Value="IIS://localhost/w3svc/${IISWebSiteID}/Root">
  <Output TaskParameter="Value" PropertyName="IISMetabasePath" />
</CreateProperty>
</Target>

When I replace the variable name with hard coded value it worked but not with variable name.

I tried couple of other things,read some old posts from others and got it working in a different way .I copied the Biztalk targets "DeployVirtualDirectory" , "DeployVDirsIIS6Plus" and "UndeployVDirs" from the BizTalkDeploymentFramework.targets file into my btdfproj file and modified it.
This is how it looks in my btdfproj file,
<Target Name="DeployVirtualDirectory">
<CreateVirtualDirectory MetabasePath="IIS://localhost/w3svc/$(IISWebSiteID)/Root" Name="%(VDirList.Vdir)" Path="$(MSBuildProjectDirectory)\%(VDirList.Physdir)" />
</Target>
<Target Name="DeployVDirsIIS6Plus" Condition="'$(IisMajorVersion)' != '5'">
<!-- Create app pool and place vdir in app pool for win2003+ -->
<AssignVirtualDirectoryToAppPool
  MetabasePath="IIS://localhost/w3svc/$(IISWebSiteID)/Root" VDirName="%(VDirList.Vdir)" AppPoolName="%(VDirList.AppPool)" />
<ConfigureAppPool
  MetabasePath="IIS://localhost/w3svc/$(IISWebSiteID)/Root" AppPoolName="%(VDirList.AppPool)" UserName="$(VDIR_UserName)" Password="$(VDIR_UserPass)"
  Condition="'$(VDIR_UserPass)' != ''" />
<Message Text="SKIPPING APP POOL IDENTITY CONFIGURATION because the property VDIR_UserPass is empty." Condition="'$(VDIR_UserPass)' == ''" />

<!-- Set the .NET runtime version on the AppPool if AppPoolNetVersion was specified; IIS 7.0+ only -->
<Exec Command="&quot;$(AppCmd)&quot; set apppool /apppool.name:&quot;%(VDirList.AppPool)&quot; /managedRuntimeVersion:&quot;%(VDirList.AppPoolNetVersion)&quot; /managedPipelineMode:Integrated"
      Condition="'$(IisMajorVersion)' != '6' and '$(Configuration)' == 'Server' and '%(VDirList.AppPoolNetVersion)' != ''" />
</Target>

<Target Name="UndeployVDirs" DependsOnTargets="SetWinVer;GetSoftwarePaths" Condition="'$(IncludeVirtualDirectories)' == 'true' and '$(SkipUndeploy)' == 'false' and '$(UndeployIISArtifacts)' == 'true'">
<!-- Delete virtual directories and relevant IIS configuration. -->
<DeleteVirtualDirectory MetabasePath="IIS://localhost/w3svc/$(IISWebSiteID)/Root" Name="%(VDirList.Vdir)" ContinueOnError="true" />
</Target>

I needed to set both DeployVDirsIIS6Plus and UndeployVDirs targets in order to delete the virtual directory when I undeploy my solution.