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

Marco picture Marco · Nov 6, 2013 · Viewed 24.5k times · Source

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.

Answer

Tommy picture Tommy · Nov 15, 2013

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