web config error: Unrecognized attribute 'xmlns:xdt'. Note that attribute names are case-sensitive
Asked Answered
L

5

21

I am trying to deploy an application to AppHarbor and followed their instructions on how to modify my web.config, so it uses their instance auf Sql server.

Upon running the solution I am getting the error mentioned in the topic:

Unrecognized attribute 'xmlns:xdt'. Note that attribute names are case-sensitive.

The only thread i found about this problem was this one. But adding the pre build lines and deleting the obj folder and rebuilding did not bring any solution. It keeps running into this exception at the line:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

Thank you in advance.

Lorou answered 6/11, 2013 at 10:52 Comment(0)
C
20

I would check that you have the following line within the top of your transform file.

<?xml version="1.0"?>

If you confirm that is there, I would also check that the following is not within your actual transformed web.config.

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

I have found the web essentials extension invaluable for resolving errors like this before I deploy.

You can simply right-click your transform file and select preview from Visual Studio and if you encounter any problems you can investigate/fix locally.

Web essentials 2012

http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6

Claudianus answered 13/11, 2013 at 12:10 Comment(5)
I just realized, that your answer is also correct, but i misread it. I somehow ignored the "not" in your sentence.Lorou
Nice one, please accept the answer. I answered 2 days before the other answer. :)Claudianus
I was to fast with the bounty, but the answer is yours. Sorry.Lorou
So do we just delete that line?Carnify
@Carnify if it's there yesClaudianus
F
31

Ensure that the line throwing the error:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

Is not in your primary web.config file. This is the line for a web.config transformation file. Basically, when you create a new project, you will get a Web.config file with one or more sub web.config files named according to the build profiles for your solution such as:

Web.config
    Web.Release.config
    Web.Debug.config

Your parent web.config file should start with <configuration> and none of the xmlns:xdt stuff. Your sub web.config files (those used for transforming your parent web.config file) should start with that line.

If you are unfamiliar with web.config transformations, this allows VS to automatically change elements of your configuration depending on the build type of the project (used for changing connection strings, turning debug on and off, etc).

Also, please check the blog postings at AppHarbor for instructions on dealing with Web.config transformations. Having never used AppHarbor, it appears you may need to make some minor project changes on your end for the transformations to work correctly. Lastly, you may need to ensure that your web.config transformation files are indeed being included in the build/deployment to app harbor

Fireball answered 15/11, 2013 at 21:25 Comment(3)
Oh dear me ... and it builds.Lorou
Thanks for explaining that it needs to not be in the PRIMARY web.config. You need it in the transformed versions of the web.config (or in my case, app.config).Higgledypiggledy
do we just delete that lineCarnify
C
20

I would check that you have the following line within the top of your transform file.

<?xml version="1.0"?>

If you confirm that is there, I would also check that the following is not within your actual transformed web.config.

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

I have found the web essentials extension invaluable for resolving errors like this before I deploy.

You can simply right-click your transform file and select preview from Visual Studio and if you encounter any problems you can investigate/fix locally.

Web essentials 2012

http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6

Claudianus answered 13/11, 2013 at 12:10 Comment(5)
I just realized, that your answer is also correct, but i misread it. I somehow ignored the "not" in your sentence.Lorou
Nice one, please accept the answer. I answered 2 days before the other answer. :)Claudianus
I was to fast with the bounty, but the answer is yours. Sorry.Lorou
So do we just delete that line?Carnify
@Carnify if it's there yesClaudianus
H
3

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.

Hermetic answered 6/3, 2014 at 15:22 Comment(1)
Sorry, but if you lose the transformation from your release-config, the whole point of it is lost?Immaterialize
T
0

I deleted the release and debug folder under Obj and re-build the code. It worked for me.

Tambourine answered 16/12, 2019 at 11:21 Comment(0)
S
0

I know this is an old Question, but none of these answers worked for me.

What did work was deleting the contents of the {project}/bin/Debug folder.

In my case, the error listed a {project}.dll.config file inside that Debug folder as having the error. (I could probably have just deleted the one file, but deleting the whole thing seemed more likely to fix other potential errors, as well.)

My app.config files are set for Do not copy in the Properties, so maybe changing that could also fix the issue, by replacing an old version of the file.

Schuller answered 6/4, 2020 at 18:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.