MSBuild error executing target WebDirectoryCreate

444 views Asked by At

I'm trying to use the WebDirectoryCreate task from the MSBuildCommunityTasks to create my virtual directory with MSBuild but it throws an Index was out of range error.

Here's the relevant part of my build script:

  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>

  ...other build targets working ok...

  <Target Name="Deploy">
    <RemoveDir Directories="$(DeploymentFolder)$(VerRevision)" ContinueOnError="true" />
    <ItemGroup>
      <DeploymentFiles Include="$(PublishOutputFolder)\**\*.*" />
    </ItemGroup>
    <Copy SourceFiles="@(DeploymentFiles)" DestinationFolder="$(DeploymentFolder)$(VerRevision)\%(RecursiveDir)" />
    <WebDirectoryDelete VirtualDirectoryName="$(VirtualDirectory)$(VerRevision)" ContinueOnError="true" />
    <WebDirectoryCreate VirtualDirectoryName="$(VirtualDirectory)$(VerRevision)" VirtualDirectoryPhysicalPath="$(DeploymentFolder)$(VerRevision)" />
  </Target>

And here's the corresponding output:

  Deleting virtual directory 'MyApp283' on 'localhost:80'.
MSBUILD : warning : The system cannot find the path specified. (Exception from HRESULT: 0x80070003) [D:\build\MyApp\Build.xml]
  The previous error was converted to a warning because the task was called with ContinueOnError=true.
  Build continuing because "ContinueOnError" on the task "WebDirectoryDelete" is set to "true".
  Creating virtual directory named MyApp283 on localhost:
D:\build\MyApp\Build.xml(50,5): error : Index was out of range. Must be non-negative and less than the size of the collection.
D:\build\MyApp\Build.xml(50,5): error : Parameter name: index
Done Building Project "D:\build\MyApp\Build.xml" (default targets) -- FAILED.

Build FAILED.

I have checked the import is correct by adding the virtual directory manually and running the build. In this case the WebDirectoryDelete task corrcetly deletes the virtual directory but WebDirectoryCreate throws the same error.

I'm executing the build using MSBuild from a simple batch file. All tasks before this one execute just fine. OS is Windows Server 2008 R2 Enterprise Edition SP1.

Can anyone give me any clues? SO and Google threw up one single link with no answer.

0

There are 0 answers