Tommy's very clear description of the transformation process allowed me to solve a very stubborn problem. I have an ASP.NET MVC 4 project that was giving an error when I was trying to publish from Visual Studio 2012. I kept getting the error
Unrecognized attribute 'xmlns:xdt'. Note that attribute names are case-sensitive.
The error said it was in the web.config file, but it actually isn’t there. It was in the Web.Release.Config.
I tried many of the recommended solutions in
Web.config transformation: Unrecognized attribute 'xmlns:xdt'. Note that attribute names are case-sensitive
I removed the contents of the obj directory, and that worked once or twice and then stopped working. I removed the attribute from Web.Release.Config,
xmlns:xdt=http://schemas.microsoft.com/XML-Document-Transform
but that gave me errors.
I tried
This is kind of a workaround, but you may add the following line to your pre-build commands:
del $(ProjectDir)obj\* /F /S /Q
Right click your project > Properties > Build Events > Pre-build.
That worked once, but not a second time.
I tried the longer version of the above solution
del "$(ProjectDir)obj\*" /F /Q
del "$(ProjectDir)obj\$(ConfigurationName)\AspnetCompileMerge\*" /F /S /Q
del "$(ProjectDir)obj\$(ConfigurationName)\CSAutoParameterize\*" /F /S /Q
del "$(ProjectDir)obj\$(ConfigurationName)\Package\*" /F /S /Q
del "$(ProjectDir)obj\$(ConfigurationName)\ProfileTransformWebConfig\*" /F /S /Q
del "$(ProjectDir)obj\$(ConfigurationName)\TempPE\*" /F /S /Q
del "$(ProjectDir)obj\$(ConfigurationName)\TransformWebConfig\*" /F /S /Q
but that gave me a lot of errors.
The site doctor had an interesting looking solution, but it required downloading pre-release software from GitHub and I didn’t want to take a chance with that if I didn’t have to.
http://blogs.thesitedoctor.co.uk/tim/Trackback.aspx?guid=7988f7bc-947c-4134-ab52-af22770b639c
Then I found Tommy's article, and it gave me an idea. I deleted this xmlns:xdt=http://schemas.microsoft.com/XML-Document-Transform
from this line
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
When I did that, I had to delete
xdt:Transform="RemoveAttributes(debug)"
from this line
<compilation xdt:Transform="RemoveAttributes(debug)" />
This worked for me. It probably isn’t a great idea to remove the transformation that seems to remove the debug attributes when you publish/release your project, but it seems to fix the problem.