01 May 2013

Using the Nugetter CodePlex project with TFS 2012 build throws TF215097 error

Problem

While working with a client recently I came across an issue that I think needs to be better documented. 

We were implementing Nuget packaging in their TFS 2012 build process.  I knew from past engagements that the Nugetter project on CodePlex is an excellent way to easily add this activity to an existing build process.

We created the build definition using the NuGetterMultiPkgBuildVersionedTemplate20.xaml build process template. When we ran the build, it failed with the following error

TF215097: An error occurred while initializing a build for build definition
[Build Definition] nuget:

Exception Message: The invocation of the constructor on type
'TfsBuild.NuGetter.Activities.NuGetterProcess' that matches the specified
binding constraints threw an exception. (type XamlObjectWriterException)


Exception Stack Trace:
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(XamlType xamlType,
Object[] args)
at System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(
ObjectWriterContext ctx)
at System.Xaml.XamlObjectWriter.WriteStartMember(XamlMember property)
at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter,
Boolean closeWriter)
at System.Activities.XamlIntegration.FuncFactory`1.Evaluate()
at System.Activities.DynamicActivity.OnInternalCacheMetadata(
Boolean createEmptyBindings)
at System.Activities.Activity.InternalCacheMetadata(Boolean createEmptyBindings,
IList`1& validationErrors)
at System.Activities.ActivityUtilities.ProcessActivity(ChildActivity childActivity,
ChildActivity& nextActivity, Stack`1& activitiesRemaining,
ActivityCallStack parentChain, IList`1& validationErrors,
ProcessActivityTreeOptions options, ProcessActivityCallback callback)
at System.Activities.ActivityUtilities.ProcessActivityTreeCore(
ChildActivity currentActivity, ActivityCallStack parentChain,
ProcessActivityTreeOptions options, ProcessActivityCallback callback,
IList`1& validationErrors)
at System.Activities.ActivityUtilities.CacheRootMetadata(Activity activity,
LocationReferenceEnvironment hostEnvironment, ProcessActivityTreeOptions options,
ProcessActivityCallback callback, IList`1& validationErrors)
at System.Activities.Validation.ActivityValidationServices
.InternalActivityValidationServices.InternalValidate()
at Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers.ValidateWorkflow(
Activity activity, ValidationSettings validationSettings)
at Microsoft.TeamFoundation.Build.Hosting.BuildProcessCache.LoadFromXaml(
String workflowXaml, TextExpressionImports textExpressionImports)
at Microsoft.TeamFoundation.Build.Hosting.BuildControllerWorkflowManager
.PrepareRequestForBuild(WorkflowManagerActivity activity, IBuildDetail build,
WorkflowRequest request, IDictionary`2 dataContext)
at Microsoft.TeamFoundation.Build.Hosting.BuildWorkflowManager.TryStartWorkflow(
WorkflowRequest request, WorkflowManagerActivity activity,
BuildWorkflowInstance& workflowInstance, Exception& error, Boolean& syncLockTaken)

Inner Exception Details:

Exception Message: Exception has been thrown by the target of an invocation.
(type TargetInvocationException)

Exception Stack Trace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments,
Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr,
Binder binder, Object[] parameters, CultureInfo culture)
at System.Activities.XamlIntegration.ActivityXamlServices.GetXamlSchemaContext(
Assembly assembly, String helperClassName)
at System.Activities.XamlIntegration.ActivityXamlServices.InitializeComponent(
Type componentType, Object componentInstance)
at TfsBuild.NuGetter.Activities.NuGetterProcess.BeforeInitializeComponent(
Boolean& isInitialized)
at TfsBuild.NuGetter.Activities.NuGetterProcess.InitializeComponent()

Inner Exception Details:

Exception Message: Could not load file or assembly 'System.Management.Automation,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
The system cannot find the file specified. (type FileNotFoundException)

Exception Stack Trace:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,
String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound,
Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,
Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark,
IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection,
Boolean suppressSecurityChecks)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at XamlStaticHelperNamespace._XamlStaticHelper.Load(String assemblyNameVal)
at XamlStaticHelperNamespace._XamlStaticHelper.LoadAssemblies()
at XamlStaticHelperNamespace._XamlStaticHelper.get_SchemaContext()

I’ve pasted the entire error message here so that it will be indexed by search engines and thus easier to find. :)

Solution

We did a little bit of searching online and followed a few dead-end trails.  We finally tracked down a discussion article on the Nugetter project’s discussion page that pointed to a mismatched PowerShell version on the build controller.

While our build controller machine was running Windows Server 2008 R2, we found that it only had PowerShell v1.0 installed.  We need to have PowerShell v3 installed for this to work.

We installed PowerShell v3 on the build controller and build agent and rebooted both machines.  When we triggered the build again it ran to completion.

I’m not sure if the updated PowerShell was necessary for the Build Agent machine but the client decided to install it anyway.

Synopsis

If you encounter this error, make sure the Build Controller box has PowerShell v3 installed on it.

0 comments:

Post a Comment