Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this web.config transform say it can't find the applicationSettings element?

Tags:

I get the following error while transforming a web.config file in TeamCity. It happens on the element, <applicationSettings xdt:Transform="Replace">.

No element in the source document matches '/configuration/applicationSettings'

The source file has this setting. Any idea how to solve this?

like image 748
sam Avatar asked Jul 27 '11 13:07

sam


People also ask

What is Web config transform?

A Web. config transformation file contains XML markup that specifies how to change the Web. config file when it is deployed. You can specify different changes for specific build configurations and for specific publish profiles.

Why is add config transform greyed out?

You need to create a configuration in a given project before it can use that transform. Either check "Create new project configurations" to create the configuration in all projects at once, or do it individually like @paulv7260 did.


2 Answers

I had to remove the namespace attribute from the configuration node. There is some conflict in the declared schema and the elements I was using.

xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0" 
like image 58
sam Avatar answered Oct 05 '22 23:10

sam


I would like to give a more detailed answer for others here.

In Visual Studio 2010 the web.config transform engine didn't respect xmlns declarations. Because of that if your source web.config had an xmlns declaration, and if you created a transform then the transformation would not work. This is because when we perform the XPath to identify the source which should be replaced we cannot find the value. In order to work around this you should remove the xmlns declaration on the source web.config as well as the transform.

With that being said, in Visual Studio 2010 SP1 we fixed the namespace bug. So your source web.config as well as your transformation must agree on the xmlns, if one has it the other must have it as well.

I suspect that you are using the pre-SP1 bits, but not sure. In order to ensure that the behavior doesn't change if you upgrade to SP1 I recommend you remove xmlns declaration from your source web.config as well as your transforms. The xmlns is not needed in the web.config file so it is safe to remove it.

like image 36
Sayed Ibrahim Hashimi Avatar answered Oct 05 '22 22:10

Sayed Ibrahim Hashimi