If for some reason either your source or transform file becomes invalid (in my case I had a variable substitution task earlier that added an &
to an attribute) the error message is less than revealing:
##[debug]Caught exception from task script.
##[debug]Error record:
##[debug]% : Exception calling "Load" with "1" argument(s): "An error occurred while parsing EntityName. Line 14, position 39."
##[debug]At D:\a\_tasks\xdttransform_98012758-c053-475d-9d6a-fd0773c39e09\2.1.0\transform.ps1:73 char:40
##[debug]+ $transforms -split "(?:`n`r?)|," | % {
##[debug]+ ~~~
##[debug] + CategoryInfo : NotSpecified: (:) [ForEach-Object], MethodInvocationException
##[debug] + FullyQualifiedErrorId : DotNetMethodException,Microsoft.PowerShell.Commands.ForEachObjectCommand
##[debug]
##[debug]Script stack trace:
##[debug]at _ApplyTransform, D:\a\_tasks\xdttransform_98012758-c053-475d-9d6a-fd0773c39e09\2.1.0\transform.ps1: line 32
##[debug]at <ScriptBlock>, D:\a\_tasks\xdttransform_98012758-c053-475d-9d6a-fd0773c39e09\2.1.0\transform.ps1: line 112
##[debug]at <ScriptBlock>, D:\a\_tasks\xdttransform_98012758-c053-475d-9d6a-fd0773c39e09\2.1.0\transform.ps1: line 73
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]at <ScriptBlock>, <No file>: line 22
##[debug]at <ScriptBlock>, <No file>: line 18
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]Exception:
##[debug]System.Management.Automation.MethodInvocationException: Exception calling "Load" with "1" argument(s): "An error occurred while parsing EntityName. Line 14, position 39." ---> System.Xml.XmlException: An error occurred while parsing EntityName. Line 14, position 39.
##[debug] at System.Xml.XmlTextReaderImpl.Throw(Exception e)
##[debug] at System.Xml.XmlTextReaderImpl.ParseEntityName()
##[debug] at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
##[debug] at System.Xml.XmlTextReaderImpl.ParseAttributes()
##[debug] at System.Xml.XmlTextReaderImpl.ParseElement()
##[debug] at System.Xml.XmlTextReaderImpl.ParseElementContent()
##[debug] at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
##[debug] at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
##[debug] at System.Xml.XmlDocument.Load(XmlReader reader)
##[debug] at Microsoft.Web.XmlTransform.XmlFileInfoDocument.LoadFromTextReader(TextReader textReader)
##[debug] at Microsoft.Web.XmlTransform.XmlFileInfoDocument.LoadFromFileName(String filename)
##[debug] at Microsoft.Web.XmlTransform.XmlFileInfoDocument.Load(String filename)
##[debug] at Load(Object , Object[] )
##[debug] at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)
##[debug] --- End of inner exception stack trace ---
##[debug] at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
##[debug] at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
##[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
##[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
##[debug] at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
##[debug] at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
##[debug] at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
##[debug] at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.<InvokeWithPipe>b__0()
##[debug] at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action)
##[debug] at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args)
##[debug] at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args)
##[debug] at Microsoft.PowerShell.Commands.ForEachObjectCommand.ProcessRecord()
##[debug] at System.Management.Automation.CommandProcessor.ProcessRecord()
##[error]Exception calling "Load" with "1" argument(s): "An error occurred while parsing EntityName. Line 14, position 39."
It would be helpful if you caught that and provided more context. For example identifying which file triggered the exception would be the minimal solution to the problem. Perhaps (in the presence of a particular variable or setting?) write out the contents of the offending file to the log because if its the result of manipulation, you're not going to know what's wrong, unless you write it out.