Friday, 26 March 2010

Visual Studio 2010 Config Transformations TransformXml task failure

Friday, 26 March 2010

So I got a little bit inspired the other day after watching Scott Hanselman’s Web Deployment Made Awesome: If You're Using XCopy, You're Doing It Wrong from MIX10. With a perfect candidate ASP.NET 3.5 web app and VS2010 RC I dived in and generated Web.Release.config and Web.Debug.config files then went to publish. Unfortunately it didn’t all go to plan and all I got was this particularly uninformative error:
The "TransformXml" task failed unexpectedly.
System.UriFormatException: Invalid URI: The URI is empty.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.Web.Publishing.Tasks.TransformXml.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)

After much toing and froing I discovered that converting the project to .NET 4 then back to .NET 3.5 solved the problem. Intrigued, I investigated further and found the root cause in an appSetting entry (values changed in this post for obvious reasons):
<appSettings>
  <add key="ServiceAccountUsername" value="domain\username" />
  <add key="ServiceAccountPassword" value="doLW0&gt;`dsP1&gt;%!a" />
</appSettings>

A quick diff against the head source control copy showed the “>” symbol had been escaped to “&gt;”. Reverting this change immediately caused the publish process to fail again. Password changed, problem solved.
I could find absolutely zero information on the web about this error message in the context of config transformations so hopefully this post will save someone else some pain one day.

Tags:

comments powered by Disqus

Leaving comments is awesome, please do. All I ask is that you be nice and if in doubt, read Comments on troyhunt.com for guidance.