Base Classes Store CodeActivityContext Which Causes Errors


There's a generic bug where the base classes store an instance of the CodeActivityContext, rather than passing the context to every activity and method. Microsoft considers this coding unsupported and results in issues with VSO when running activities from multiple XAML builds running at the same time. These errors can occur if this isn't changed:

Exception Message: An Activity can only get the location of arguments which it owns. Activity 'GetLastGoodBuild' is trying to get the location of argument 'FailBuildOnError' which is owned by activity 'IsSourceChanged'. (type InvalidOperationException)
Exception Stack Trace: at System.Activities.RuntimeArgument.GetLocation(ActivityContext context)
at System.Activities.ActivityContext.GetValueCoreT
at TfsBuildExtensions.Activities.BaseCodeActivity1.LogBuildError(String errorMessage) at TfsBuildExtensions.Activities.BaseCodeActivity1.Execute(CodeActivityContext context)
at System.Activities.CodeActivity`1.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)