Unable to use methodology because work item queries have encoding information removed from the X

I am loving this tool....absolutely loving it.

However, I believe I've found an issue when performing some edits on the methodology with it. I can't always determine what causes this, but sometimes the editor removes the following line from all the work item queries:

<?xml version="1.0" encoding="utf-8"?>

...so for example the AllWorkItems.wiq file is changed from this:

<?xml version="1.0" encoding="utf-8"?>
<WorkItemQuery Version="1">
<Wiql>SELECT [System.Id], [System.WorkItemType], [System.State], [System.AssignedTo], [System.Title] FROM WorkItems
WHERE [System.TeamProject] = @project
ORDER BY [System.WorkItemType], [System.Id]

</Wiql>
</WorkItemQuery>

...to this:

<WorkItemQuery Version="1">
<Wiql>SELECT [System.Id], [System.WorkItemType], [System.State], [System.AssignedTo], [System.Title] FROM WorkItems
WHERE [System.TeamProject] = @project
ORDER BY [System.WorkItemType], [System.Id]

</Wiql>
</WorkItemQuery>

What ultimately happens is you are allowed to import the methodology into the server with no problems. However, when you try to make a project with it you get an exception when it attempts to import these queries like the following:

2007-03-02 13:51:35Z | Module: Work Item Tracking | Thread: 14 | The query named 'Blocked Work Items' has been imported from 'C:\Documents and Settings\...\Local Settings\Temp\TPW_tmp11E.tmp\WorkItem Tracking\Queries\BlockedWorkItems.wiq'
begin Exception entry
Time: 2007-03-02 13:51:35Z
Module: Engine
Event Description: TF30162: Task "Queries" from Group "WorkItemTracking" failed
Exception Type: Microsoft.TeamFoundation.Client.PcwException
Exception Message: Error Creating Query Change Requests from C:\Documents and Settings\...\Local Settings\Temp\TPW_tmp11E.tmp\WorkItem Tracking\Queries\ChangeRequests.wiq
Stack Trace:
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.Execute(ProjectCreationContext ctxt, XmlNode taskXml)
at Microsoft.VisualStudio.TeamFoundation.ProjectCreationEngine.TaskExecutor.PerformTask(IProjectComponentCreator componentCreator, ProjectCreationContext context, XmlNode taskXml)
at Microsoft.VisualStudio.TeamFoundation.ProjectCreationEngine.RunTask(Object taskObj)
-- Inner Exception --
Exception Type: Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwFatalException
Exception Message: Error Creating Query Change Requests from C:\Documents and Settings\samstor\Local Settings\Temp\TPW_tmp11E.tmp\WorkItem Tracking\Queries\ChangeRequests.wiq
Stack Trace:
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.WitPcwTask.StoredQueryTask.AddQuery(String name, String file)
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.WitPcwTask.StoredQueryTask.Execute()
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.Parse(ContextWrapper wrapper, XmlNode taskXml, Boolean fExecute)
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.Execute(ProjectCreationContext ctxt, XmlNode taskXml)
-- end Inner Exception --
-- Inner Exception --
Exception Type: System.Xml.XmlException
Exception Message: Invalid character in the given encoding. Line 1, position 1.

Stack Trace:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.InvalidCharRecovery(Int32& bytesCount, Int32& charsCount)
at System.Xml.XmlTextReaderImpl.GetChars(Int32 maxCharsCount)
at System.Xml.XmlTextReaderImpl.ReadData()
at System.Xml.XmlTextReaderImpl.SwitchEncoding(Encoding newEncoding)
at System.Xml.XmlTextReaderImpl.ParseXmlDeclaration(Boolean isTextDecl)
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlCharCheckingReader.Read()
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.QueryDocument.ServerNameFromWiqFile(String path)
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.QueryDocument.LoadFromFile(String path)
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.QueryDocument.UploadQuery(String tfsServer, String projectName, String wiqFilePath, String queryName, QueryScope scope)
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.WitPcwTask.StoredQueryTask.AddQuery(String name, String file)
-- end Inner Exception --
end Exception entry

Has anyone else encountered this? If I add this line back in things work correctly again. Is this a bug or am I using the tool wrong?

[5750 byte] By [Ditaka] at [2008-3-6]
# 1
Sorry for the formatting but I can't seem to change the font sizes of the first couple of passages to what I want...
Ditaka at 2007-9-6 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server – Power Tools & Add-ons...
# 2
Definitely sounds like a bug - the prologue shouldn't be removed, and given the error message, the actual file encoding may be getting busted as well (removing the BOM or changing it from utf-8 to something else).

Please file a bug on connect.microsoft.com under Visual Studio and make sure to mention this is part of Team Foundation Server so it gets routed to us.

Thanks for the feedback!

JamesManning-MSFT at 2007-9-6 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server – Power Tools & Add-ons...
# 3
Just for completeness here's the bug I submitted:

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=261820

Ditaka at 2007-9-6 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server – Power Tools & Add-ons...

Visual Studio Team System

Site Classified