TFS Build error, 'Index (zero based) must be greater than or equal to zero and less than the size of the argument list” when building XAML projects
We had an interesting issue of late building a Surface2 application solution within a TFS 2010 build system. The solution built fine in VS2010 on both my development PC and also using VS2010 on my TFS build box (both Windows 7 64bit PC), so I know I had all the right SDKs in place. However if I built it via TFS 2010 Team Build I got the error
App.xaml (136): Unknown build error, 'Index (zero based) must be greater than or equal to zero and less than the size of the argument list…”
This error appeared after we added this new block of XAML code
\- this was the line the error was reported on
I assumed the issue was that Visual Studio was somehow able to resolve an assembly reference that MSBuild could not.
so to try to resolve this I copied the MSBuild command line that was being run by the TFS build from the build log and ran it in a command prompt on my build box. Happily I got the same error, so at least it was repeatable. I then removed options on the command line until I had the minimum to give the errors. I ended up with
C:WindowsMicrosoft.NETFramework64v4.0.30319MSBuild.exe "C:Builds7SurfaceExternal Concierge CISourcesBlackMarble Concierge.sln"
If I changed to
MSBuild.exe "C:Builds7SurfaceExternal Concierge CISourcesBlackMarble Concierge.sln"
the error when away, so it had to be the version of MSBuild. When I used the 32bit version (picked up by default via the PATH) all was OK, the 64Bit gave the error.
So my fix was just to force the build to run x86 and all was OK