views:

105

answers:

1

I overrode the following target in my TFS build file to run various tasks that set up databases, import data, etc., etc. in Visual Studio 2008 - the aim was to stop only the website associated with an application pool on the server instead of stopping the entire W3SVC service on the entire machine (see alternate task for example):

<Target Name="AfterCompile">

   <AppPoolController ApplicationPoolName="$(AppPoolName)" Action="Stop" ServerName="$(WebsiteMachine)" />

   <!--<MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Stop" MachineName="$(WebsiteMachine)"  ServiceName="W3SVC"/>-->


   <!-- various tasks and what not, which have been confirmed to work fine with the option of stopping the W3SVC -->

   <AppPoolController ApplicationPoolName="$(AppPoolName)" Action="Start" ServerName="$(WebsiteMachine)" />
</Target>

However, when I try a build, I get the following:

$(BuildDirectoryPath)\BuildType\TFSBuild.proj(81,5): error : Index was outside the bounds of the array.

The various tasks mentioned above are just that: tasks, calls to other targets, etc. So where is the source of the error? I have read the MSBuild Community Tasks documentation, but the closest thing to anything resembling an array is an Enum on the Action property. It seems that other people get the same error with different applications using XML, but so far I haven't been able to find anything enlightening. I have also tried going off this, but to no avail, unless I missed something (which is very possible).

A: 

The error is probably from an exception thrown by code within the task. Index out of bounds can by thrown by a string-indexed property, maybe the AppPool name is not coming through correctly.

Take a look at the source of the task and check for array or property indexing.

Alternatively, you could just use an Exec task to shell out to iisapp.vbs.

Aidan Ryan
Turns out I was using an outdated version of Community Tasks. I did not get to test the latest version with the fix yet since I'm not in charge of the build machine and can't install random stuff on the server :)
k4k4sh1