This project is read-only.

Xml Build Activity- TextEncoding property exception!

Feb 19, 2013 at 11:13 AM
Edited Feb 19, 2013 at 11:14 AM
Hi,

I am trying to use the Xml Activity from TFS Build Extensions in my custom build template.
When I add this activity to the workflow designer, the property TextEncoding is set to "System.Text.UTF8Encoding" by default.
When I save the xaml, the Workflow Designer throws the following error:
System.Xaml.XamlObjectWriterException: 'Set property '{clr-namespace:TfsBuildExtensions.Activities.Xml;assembly=TfsBuildExtensions.Activities}Xml.TextEncoding' threw an exception.' Line number '896' and line position '412'. ---> System.ArgumentException: 'System.Text.UTF8Encoding' is not a supported encoding name.
Parameter name: name

at System.Globalization.EncodingTable.internalGetCodePageFromName(String name)
at System.Globalization.EncodingTable.GetCodePageFromName(String name)
at TfsBuildExtensions.Activities.Xml.Xml.set_TextEncoding(String value) in d:\Projects\CodePlex\teambuild2010contrib\CustomActivities\MAIN\Source\Activities\Xml\Xml.cs:line 84
--- End of inner exception stack trace ---
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
at System.Xaml.XamlObjectWriter.Logic_ApplyPropertyValue(ObjectWriterContext ctx, XamlMember prop, Object value, Boolean onParent)
at System.Xaml.XamlObjectWriter.Logic_DoAssignmentToParentProperty(ObjectWriterContext ctx)
at System.Xaml.XamlObjectWriter.WriteEndMember()
at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
at System.Activities.Presentation.Xaml.ErrorTolerantObjectWriter.XamlFragment.WriteTo(XamlWriter writer, Boolean parentHasError)
at System.Activities.Presentation.Xaml.ErrorTolerantObjectWriter.ActivityFragment.WriteTo(XamlWriter writer, Boolean parentHasError)
at System.Activities.Presentation.Xaml.ErrorTolerantObjectWriter.XamlFragment.WriteTo(XamlWriter writer, Boolean parentHasError)
at System.Activities.Presentation.Xaml.ErrorTolerantObjectWriter.ActivityFragment.WriteTo(XamlWriter writer, Boolean parentHasError)
at System.Activities.Presentation.Xaml.ErrorTolerantObjectWriter.XamlFragment.WriteTo(XamlWriter writer, Boolean parentHasError)
_ at System.Activities.Presentation.Xaml.ErrorTolerantObjectWriter.ActivityFragment.WriteTo(XamlWriter writer, Boolean parentHasError)
at System.Activities.Presentation.Xaml.ErrorTolerantObjectWriter.XamlFragment.WriteTo(XamlWriter writer, Boolean parentHasError)
at System.Activities.Presentation.Xaml.ErrorTolerantObjectWriter.ActivityFragment.WriteTo(XamlWriter writer, Boolean parentHasError)
at System.Activities.Presentation.Xaml.ErrorTolerantObjectWriter.XamlFragment.WriteTo(XamlWriter writer, Boolean parentHasError)
at System.Activities.Presentation.Xaml.ErrorTolerantObjectWriter.CompleteLoad()
at System.Activities.Presentation.Xaml.ErrorTolerantObjectWriter.WriteEndObject()
at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
at Microsoft.Activities.Presentation.Xaml.WorkflowDesignerXamlHelper.DeserializeString(String text, DeserializationMode mode, IList1& loadErrors, Dictionary2& sourceLocations)
at Microsoft.Activities.Presentation.Xaml.WorkflowDesignerXamlHelper.DeserializeString(String text, IList1& loadErrors, Dictionary2& sourceLocations)
at Microsoft.Activities.Presentation.Xaml.WorkflowDesignerXamlHelper.SerializeToString(Object obj, String fileName)
at System.Activities.Presentation.WorkflowDesigner.WriteModelToText(String fileName)

I need help resolving this issue.
I am using Visual Studio 2012 Update 1 in the preconfigured demo image from Brian Keller.
The regional settings are set to English (USA).
I am using the Build Extensions from August 2012. I have compared the xml.cs to the newer one released in January 2013 and the files do not differ.

I additionally tried typing following values in the TextEncoding property, and got similar exceptions:
  • "UTF-8" -->System.ArgumentException: 'System.Text.UTF8Encoding' is not a supported encoding name.
  • "UTF-16" -->System.ArgumentException: System.Text.UnicodeEncoding' is not a supported encoding name.
  • "windows-1252" --> System.ArgumentException: 'System.Text.SBCSCodePageEncoding' is not a supported encoding name.
Thanx,
Ana
Feb 19, 2013 at 4:32 PM
I have a repro. taking a look.
Feb 19, 2013 at 5:55 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Feb 19, 2013 at 5:59 PM
I think this is now fixed. Can you compile the latest or try this: https://www.sugarsync.com/pf/D137274_68960556_6832951 (this is the 2012 version)

thanks

Mike
Feb 20, 2013 at 11:24 AM
Hi Mike,

thank you for the quick correction.
The Xml activity in the dll you provided does not throw the exception any more. The default value for TextEncoding is now set to "utf-8".

Additional question:

I need the support for the XSLT document() function in my xslt. As stated on MSDN the default value of XsltSettings.EnableDocumentFunction is false, and the Transform() method in the xml.cs does not set it to true.

Could you expose the EnableDocumentFunction property as an additional property of the XML activity, so that it can be set in the build template workflow designer?

Thank you, cheers,
Ana Roje Ivancic
Feb 20, 2013 at 5:55 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Feb 20, 2013 at 6:04 PM
Can you try the latest code.

Mike
Feb 20, 2013 at 9:53 PM
Could tou please provide the appropriate dll?
I have not downloaded the project and can not compile it locally :)
Thanx,
Ana
Feb 20, 2013 at 10:08 PM
Feb 20, 2013 at 10:56 PM
Thank you, it works fine.
The property EnableDocumentFunction can be now controlled from outside.

Cheers,
Ana
Feb 20, 2013 at 11:56 PM
Edited Feb 20, 2013 at 11:57 PM
Hi Mike,

I made one step further and then stopped again :(.

So, I am using the Xml Activity to parse an XML file and get the result as a HTML file (written on disk - so I use the OutputFile property).
My XSLT contains therefore the following element:
<xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>

The Transform() method does the transformation correctly and then reports another exception.
The build log shows:
[...]
Xml
Initial Property Values
EnableDocumentFunction = True
FailBuildOnError = False
IgnoreExceptions = False
Indent = False
LogExceptionStack = True
OmitXmlDeclaration = False
OutputFile = MyResult.html
SchemaFiles =
TreatWarningsAsErrors = False
XmlFilePath = MyXml.xml
XmlText =
XslTransform =
XslTransformFile = MyXslt.xsl
Loading XmlFile: MyXml.xml
Transforming: MyXml.xml
Loading XslTransformFile: System.Activities.InArgument`1[System.String]
Running XslTransform
Writing using XML method
Error: The 'META' start tag on line 3 position 6 does not match the end tag of 'head'. Line 84, position 5.. Stack Trace: at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag)
at System.Xml.XmlTextReaderImpl.ParseEndElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Load(TextReader textReader, LoadOptions options)
at TfsBuildExtensions.Activities.Xml.Xml.Transform()
at TfsBuildExtensions.Activities.BaseCodeActivity.Execute(CodeActivityContext context).
Final Property Values
EnableDocumentFunction = True
FailBuildOnError = False
IgnoreExceptions = False
Indent = False
IsValid = False
LogExceptionStack = True
OmitXmlDeclaration = False
Output = <html lang="en">
<head> <META http-equiv="Content-Type" content="text/html; charset=utf-16"> <title>Analysis Information</title> <style type="text/css"> [...] </style> </head> <body>
<table class="toc" border="0"> [...] </table> </body>
</html>
OutputFile = MyResult.html
SchemaFiles =
TreatWarningsAsErrors = False
XmlFilePath = MyXml.xml
XmlText =
XslTransform =
XslTransformFile = MyXslt.xsl


I took a look at the code, and when the xslt output type is NOT set to text, it tries to use the XML method ("Writing using XML method").
In my case, the Output is already formated as HTML and it cannot be loaded as XML.

Could you please add the option to handle the xslt HTML output type correctly?

Thank you in advance,
Ana

p.s. please update the appropriate dll as well.
Feb 21, 2013 at 12:43 AM
ok. i'll prob get time to look at this tomorrow.

Thanks for all the feedback.

Mike