Error deploying Virtual DIrectory

Topics: IIS and Web Services
Sep 19, 2012 at 1:14 PM
Edited Sep 19, 2012 at 1:18 PM
Hi there, I have added Virtual Directory to my project and it throws error while installing the MSI as below:

"C:\Program Files (x86)\BizTalkAppName for BizTalk\1.0\Deployment\BizTalkAppName.Deployment.btdfproj" (Deploy target
) (1) ->
(DeployVDirs target) ->
  C:\Program Files (x86)\BizTalkAppName for BizTalk\1.0\Deployment\BizTalkAppName.Deployment.btdfproj(117,5): error
MSB4018: The "CreateVirtualDirectory" task failed unexpectedly.\r
C:\Program Files (x86)\BizTalkAppName for BizTalk\1.0\Deployment\BizTalkAppName.Deployment.btdfproj(117,5): error MS
B4018: System.Runtime.InteropServices.COMException (0x800700B7): Cannot create a file when that file already exists. (Except
ion from HRESULT: 0x800700B7)\r
C:\Program Files (x86)\BizTalkAppName for BizTalk\1.0\Deployment\BizTalkAppName.Deployment.btdfproj(117,5): error MS
B4018:    at System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsContainer.Create(String className, String relativeName
)\r
C:\Program Files (x86)\BizTalkAppName for BizTalk\1.0\Deployment\BizTalkAppName.Deployment.btdfproj(117,5): error MS
B4018:    at System.DirectoryServices.DirectoryEntries.Add(String name, String schemaClassName)\r
C:\Program Files (x86)\BizTalkAppName for BizTalk\1.0\Deployment\BizTalkAppName.Deployment.btdfproj(117,5): error MS
B4018:    at DeploymentFramework.BuildTasks.CreateVirtualDirectory.Execute()\r
C:\Program Files (x86)\BizTalkAppName for BizTalk\1.0\Deployment\BizTalkAppName.Deployment.btdfproj(117,5): error MS
B4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()\r
C:\Program Files (x86)\BizTalkAppName for BizTalk\1.0\Deployment\BizTalkAppName.Deployment.btdfproj(117,5): error MS
B4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingCo
ntext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
Thanks, Rik
Coordinator
Sep 19, 2012 at 3:07 PM

From the error "Cannot create a file when that file already exists" I'd say that the vdir already exists.  Are you on IIS 7?  I've seen the combination of application and vdir get in a bad state in IIS 7 where it's hard to get both of them deleted.  Have you made sure the vdir and any IIS application of the same name are gone first?

Thanks,
Tom

Sep 19, 2012 at 4:59 PM
Edited Sep 19, 2012 at 5:03 PM

Tom,

Thanks for the response on this.

Yes, I'm using IIS 7 and has IIS 6 compatibility features installed on it as well I have another service with different name running on this machine successfully (not deployed using BTDF).

I made sure that neither the application nor the Virtual directory exist on the server.

I have added this in the PropertyGroup: 

<UndeployIISArtifacts>true</UndeployIISArtifacts>
Below code as ItemGroup:
  <ItemGroup>
    <VDirList Include="*">
      <Vdir>MyService</Vdir>
      <Physdir>..\MyService</Physdir>
      <AppPool>MyAppPool</AppPool>
      <!--<AppPoolNetVersion>v4.0</AppPoolNetVersion>-->
    </VDirList>
  </ItemGroup>
 
Below code as Target:
<!-- Create our virtual directories, and handle service account assignment. -->
  <Target Name="DeployVDirs" DependsOnTargets="SetWinVer;GetSoftwarePaths" Condition="'$(IncludeVirtualDirectories)' == 'true'">
    <!-- Deploy virtual directories and handle service account assignment. -->

    <ItemGroupFromCSVFile ColumnNames="$(VdirListFileColumns)" Filename="$(VdirListFile)" Condition="'@(VDirList)' == ''">
      <Output TaskParameter="ItemGroup" ItemName="VDirList" />
    </ItemGroupFromCSVFile>

    <CreateVirtualDirectory
      MetabasePath="$(IISMetabasePath)" Name="%(VDirList.Vdir)" Path="$(MSBuildProjectDirectory)\%(VDirList.Physdir)" />

    <!-- Make sure aspnet account can read physical directory & its contents.  
         For workstation deployments, you would need to supply the account value through an MSBuild property. -->
    <Message Text="Modifying NTFS permissions on virtual directory folders..." Condition="'$(ModifyNTFSPermissionsOnVDirPaths)' == 'true'" />
    <Exec Command="cacls &quot;%(VDirList.Physdir)&quot; /E /G aspnet:R"
          Condition="'$(ModifyNTFSPermissionsOnVDirPaths)' == 'true' and '$(IisMajorVersion)' == '5'" />
    <Exec Command="cacls &quot;%(VDirList.Physdir)\*.*&quot; /E /G aspnet:R"
          Condition="'$(ModifyNTFSPermissionsOnVDirPaths)' == 'true' and '$(IisMajorVersion)' == '5'" />

    <!-- Take the username value from install wizard if doing a formal install -->
    <Exec Command="cacls &quot;%(VDirList.Physdir)&quot; /E /G $(VDIR_UserName):R"
          Condition="'$(ModifyNTFSPermissionsOnVDirPaths)' == 'true' and ('$(IisMajorVersion)' == '6' or '$(IisMajorVersion)' == '7') and '$(Configuration)' == 'Server'" />
    <Exec Command="cacls &quot;%(VDirList.Physdir)\*.*&quot; /E /G $(VDIR_UserName):R"
          Condition="'$(ModifyNTFSPermissionsOnVDirPaths)' == 'true' and ('$(IisMajorVersion)' == '6' or '$(IisMajorVersion)' == '7') and '$(Configuration)' == 'Server'" />

    <Exec Command="cacls &quot;%(VDirList.Physdir)&quot; /E /G $(AppPoolAccount):R"
          Condition="'$(ModifyNTFSPermissionsOnVDirPaths)' == 'true' and ('$(IisMajorVersion)' == '6' or '$(IisMajorVersion)' == '7') and '$(Configuration)' != 'Server'" />
    <Exec Command="cacls &quot;%(VDirList.Physdir)\*.*&quot; /E /G $(AppPoolAccount):R"
          Condition="'$(ModifyNTFSPermissionsOnVDirPaths)' == 'true' and ('$(IisMajorVersion)' == '6' or '$(IisMajorVersion)' == '7') and '$(Configuration)' != 'Server'" />
    <Message Text="Done modifying NTFS permissions on virtual directory folders." Condition="'$(ModifyNTFSPermissionsOnVDirPaths)' == 'true'" />

    <!-- Set package identity for winxp or win2000 -->
    <Exec
       Command="&quot;$(Cscript)&quot; /nologo &quot;$(DeployTools)\SetPackageIdentity.vbs&quot; &quot;IIS-{Default Web Site//Root/%(VDirList.Vdir)}&quot;"
       Condition="'$(IisMajorVersion)' == '5' and '$(Configuration)' == 'Server'" />

       <AssignVirtualDirectoryToAppPool
      MetabasePath="$(IISMetabasePath)" VDirName="%(VDirList.Vdir)" AppPoolName="%(VDirList.AppPool)"
      Condition="('$(IisMajorVersion)' == '6' or '$(IisMajorVersion)' == '7')" />
        <Exec
       Command="BTSTask.exe AddResource -Type:WebDirectory -Source:&quot;http://localhost/%(VDirList.Vdir)&quot; -ApplicationName:&quot;$(BizTalkAppName)&quot;"
       Condition="'$(IncludeCompsAndVDirsAsResources)' == 'true'"/>

    <!-- We are setting up our biztalk isapi extension as web svc extension for 2003 -->

    <!-- We remove in case it is already there.  We could have DeployVDirs depend on UndeployVDirs instead,
           but that seems excessive since the vdir portion itself doesn't require that. -->
    <CreateItem Include="$(MSBuildProjectDirectory)\$(WseExtensionPath)\$(Btshttpreceive)">
      <Output TaskParameter="Include" ItemName="BtsHttpReceivePath" />
    </CreateItem>

    <ConfigureWebServiceExtension
      MetabasePath="$(IISMetabasePath)"
      ExtensionFile="@(BtsHttpReceivePath->'%(FullPath)')" ExtensionName="$(WseExtensionName)" Remove="True"
      ContinueOnError="true"
      Condition="('$(IisMajorVersion)' == '6' or '$(IisMajorVersion)' == '7') and '$(WseExtensionPath)' != ''" />

    <ConfigureWebServiceExtension
      MetabasePath="$(IISMetabasePath)"
      ExtensionFile="@(BtsHttpReceivePath->'%(FullPath)')" ExtensionName="$(WseExtensionName)"
      Condition="('$(IisMajorVersion)' == '6' or '$(IisMajorVersion)' == '7') and '$(WseExtensionPath)' != ''" />
  </Target>

  <Target Name="CustomRedist">
    <MakeDir Directories="$(RedistDir)\MyService" />

    <!-- Force MSBuild to expand the item spec into physical file specs -->
    <CreateItem Include="C:\inetpub\wwwroot\MyService\**\*.*">
      <Output TaskParameter="Include" ItemName="TestFilesSourceGroup" />
    </CreateItem>

    <!-- Copy all of the files and subfolders from ..\TestFiles to $(RedistDir)\TestFiles -->
    <Copy DestinationFolder="$(RedistDir)\MyService\%(RecursiveDir)" SourceFiles="@(TestFilesSourceGroup)"/>
  </Target>

Coordinator
Sep 19, 2012 at 5:15 PM

For that Target, did you copy from the BTDF targets file, or do you have that in your .btdfproj?

Sep 19, 2012 at 5:17 PM

I added this to my btdfproj file.

Coordinator
Sep 19, 2012 at 5:22 PM

OK, was that done pre-5.0 final release to fix an issue?  Do you remember what was customized?  I would advise first removing that from your .btdfproj if possible and use the default target.

Aside from that, have you tried changing the app pool and vdir names to see if the error is specific to particular names?

Thanks,
Tom

Sep 19, 2012 at 6:19 PM
Edited Sep 19, 2012 at 9:19 PM

Tom,

I'm using BTDF 5.0 (JulyRelease I believe) with VS 2010, WIndows 2008, BizTalk2010.

I used default target this time and found that the Physical files were dropped on to the vDir folder and the app/service was created but the service wasn't pointed to the Physical Location and the AppPool wasn't set correctly eventhough I specified in the btdf proj file.

I'm getting error as

"C:\Program Files (x86)\MyApplicationName for BizTalk\1.0\Deployment\MyApplicationName.Deployment.btdfproj" (Deploy target) (1) ->
(DeployVDirs target) ->
  C:\Program Files (x86)\MyApplicationName for BizTalk\1.0\Deployment\Framewor
k\BizTalkDeploymentFramework.targets(1713,5): error MSB3073: The command "cacls
 "MyApplicationName" /E /G :R" exited with code 2. [C:\Program Files (x86)\Mlits
.BTS.AddVerif for BizTalk\1.0\Deployment\Mlits.BTS.AddVerif.Deployment.btdfproj
]

Thanks, Rik

 

 

Coordinator
Sep 20, 2012 at 5:06 AM

Rik, have you tested and verified correct operation first while deploying through Visual Studio?  I see that you are deploying in Server mode; I assume from an MSI install.

I can see that you do not have some required MSBuild properties defined.  Are you using the install wizard or scripting the install?  You do not have $(VDIR_UserName) defined, which probably means there are a couple others undefined too.  This is normally set by the install wizard and defined via the InstallWizard.xml (discussed here).  You'll find an example of this in the Advanced sample.  If you're trying to script the install then you must provide these property values through the command line.

Also, you can uncomment the AppPoolNetVersion -- it is supported in the final 5.0 release.

Thanks,
Tom

Sep 24, 2012 at 3:00 PM
Edited Sep 24, 2012 at 3:01 PM

Tom,

Thanks for the insight.

I tested it deploying through VS 2010 successfully. Can you point me to the CommandLine Script where I can pass the UserName/Password? The wizard only asks for the Username not Password, if I'm not wrong.

Thanks, Rik

Coordinator
Sep 25, 2012 at 4:38 AM

Hi Rik,

The password is also collected by the wizard.  Check out the Advanced sample's InstallWizard.xml.

As for scripting/automating the MSI-based deployment (skipping the wizard altogether), the documentation is here.

Thanks,
Tom

Sep 25, 2012 at 8:45 PM

Thanks Tom. Seems that was the major thing I was missing. Appreciate your help.

Oct 3, 2012 at 12:52 PM
Edited Oct 3, 2012 at 1:40 PM

Tom,

Is there any document/s on how can I deploy multiple SSO Applications with one btdf project-MSI?

Thanks, Rike

Coordinator
Oct 3, 2012 at 3:59 PM

It's not a built-in feature, but you can add a target that is scheduled after the DeploySSO target and call out to the same command-line tools that the normal SSO deployment process uses (in DeployTools folder).

Thanks,
Tom

Dec 12, 2013 at 10:53 PM
Perhaps someone can take benefit from my experience.

I got the same error "Cannot create a file when that file already exists." and here is what I did that fixed the issue.

I manually created a new virtual directory using the same settings which I have defined in the btdfproj file e.g: same VDir name, same physical path and same Application Pool.
Restarted the IIS.

Redeploy the MSI and it worked.

Tahir
Jun 4, 2014 at 11:52 AM
Edited Jun 10, 2014 at 8:59 AM
Thanks to "tahirhemani" ...

I had the same issue with the "Cannot create a file", and the suggestion of manually creating the vdir fixed the issue

In subsequent deployments the DeployVirtualDirectory either reconfigured the existing vdir ...
Target DeployVirtualDirectory:
    Virtual directory 'Purchase.Orchestrations' already exists. Reconfiguring existing vdir.
or when I deleted the vdir to check, it was re-created fine ...
    Virtual directory 'Purchase.Orchestrations' created/updated with path 'C:\Program Files (x86)\...