Web.config conversion: unrecognized attribute 'xmlns: xdt'. Please note that attribute names are case sensitive.

I get this strange inconsistent error in an MVC 3.0 project. When I create a project, sometimes the following error message appears:

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

This refers to the standard tranformation web.config file (copy of Web.Release.config) There are no other errors or warnings. This happens in debug and release mode. Sometimes it clears up if I clear the solution

BEGIN UPDATE

Problem detected. In the MVC Project file (MyProject.csproj) I set the assembly views to true

<MvcBuildViews>true</MvcBuildViews> 

After returning to false, the above error will disappear. I would like to have a view assembly as it stops a lot of stupid view code errors, etc. And is a performance improvement (pages are precompiled instead of jit)

Does anyone know that this is causing an error? this is mistake?

END UPDATE

 <?xml version="1.0"?> <!-- For more information on using Web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 --> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <!-- In the example below, the "SetAttributes" transform will change the value of "connectionString" to use "ReleaseSQLServer" only when the "Match" locator finds an atrribute "name" that has a value of "MyDB". <connectionStrings> <add name="MyDB" connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings> --> <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> <!-- In the example below, the "Replace" transform will replace the entire <customErrors> section of your Web.config file. Note that because there is only one customErrors section under the <system.web> node, there is no need to use the "xdt:Locator" attribute. <customErrors defaultRedirect="GenericError.htm" mode="RemoteOnly" xdt:Transform="Replace"> <error statusCode="500" redirect="InternalError.htm"/> </customErrors> --> </system.web> </configuration> 
+43
web-config asp.net-mvc-3
Oct 05
source share
11 answers

I ran into the same problem. You will find many jokes related to MvcBuildViews and various error conditions. But no one mentions this particular mistake. The quick fix that worked for me was to delete the contents of the "obj" directory for the affected web project and then restore it.

+76
Nov 16 '12 at 16:24
source share

This is a kind of workaround, but you can add the following line to your pre-build commands:

del $(ProjectDir)obj\* /F /S /Q

Right-click your project> Properties> Build Events> Pre Build

+31
Jan 11 '13 at 13:51
source share

This works with Continuous Integration and WebDeploy:

This problem occurs when I install

 <MvcBuildViews>true</MvcBuildViews> 

in my project file that I need .

After reading and testing everything that I found about this problem, I have wokraround, which also works with WebDeploy through MSBuild

 MSBUild.exe ... /p:DeployOnBuild=true 

You (only) need to delete the TransformWebConfig subfolder in your team folder during the events before and after the build. It works even with continuous integration servers that break if there is no folder

Pre-build event command line:

 if exist "$(ProjectDir)obj\$(ConfigurationName)\transformwebconfig\" del "$(ProjectDir)obj\$(ConfigurationName)\transformwebconfig\*" /F /S /Q 

Post-build event command line:

 if exist "$(ProjectDir)obj\$(ConfigurationName)\transformwebconfig\" del "$(ProjectDir)obj\$(ConfigurationName)\transformwebconfig\*" /F /S /Q 

This even works great with Resharper , which sometimes gets confused if you delete the entire obj folder.

Be sure to set the Run the post-build event parameter to always !!

UPDATE: Replaced debugging and release using $ (ConfigurationName) and removed the resulting duplicate line

+8
Apr 10 '14 at 7:49
source share

I resolve my conflict by doing the same thing that Job said. Delete Attribute

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

From the main Web.config and leave it in the file Web.debug.config and Web.release.config

+1
Dec 20 '13 at 16:02
source share

There is another workaround from Microsoft Team. See here for more details.

Just copy this snippet to your .csproj or .vbproj file:

 <PropertyGroup> <_EnableCleanOnBuildForMvcViews Condition=" '$(_EnableCleanOnBuildForMvcViews)'=='' ">true</_EnableCleanOnBuildForMvcViews> </PropertyGroup> <Target Name="CleanupForBuildMvcViews" Condition=" '$(_EnableCleanOnBuildForMvcViews)'=='true' and '$(MVCBuildViews)'=='true' " BeforeTargets="MvcBuildViews"> <ItemGroup> <_TempWebConfigToDelete Include="$(BaseIntermediateOutputPath)**\Package\**\*" /> <_TempWebConfigToDelete Include="$(BaseIntermediateOutputPath)**\TransformWebConfig\**\*" /> <_TempWebConfigToDelete Include="$(BaseIntermediateOutputPath)**\CSAutoParameterize\**\*" /> <_TempWebConfigToDelete Include="$(BaseIntermediateOutputPath)**\TempPE\**\*" /> </ItemGroup> <Delete Files="@(_TempWebConfigToDelete)" /> </Target> 

This automates the process of cleaning the obj folder using build objects.

+1
Dec 18 '15 at 13:47
source share

I found this to work better for me:

 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 

otherwise, the edmxResourcesToEmbed complaint assembly disappears.

0
Jun 21 '13 at 15:05
source share

just remove the xmlns: xdt attribute from web.config, but save it in web.release.config and web.debug.config.

Your conversion will still work - and your website will also.

0
Aug 27 '13 at 18:57
source share

I saw it too. In particular, it was reproducible when changing between assembly configurations in Visual Studio.

My workaround previously was to delete everything in the \obj folder, but after carefully reading my web.config, I found that it had some erroneous text sitting outside the element (i.e. it was invalid XML) .

Apparently, the config conversions simply absorbed the exception when trying to perform the conversion.

The error of my web.config is fixed, and now everything works as expected.

Hope this helps someone

0
Aug 17 '14 at 10:42 on
source share

I also ran into this problem. For me, this was due to the fact that I created a new debug configuration called "DevDebug". I fixed it by making a copy of web.debug.config called web.DevDebug.config and adding it to the project.

Then, when I tried to start the aspnet compiler, he was satisfied that he was able to find the correct configuration configuration for the merge file.

0
Jan 23 '15 at 2:06
source share

I just change below to web.config

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

to

 <configuration> 

Fixed problem

0
Feb 12 '15 at 12:03
source share
  • Right-click the project, click Publish
  • Go to SettingsFile Publishing Options
  • Uncheck the Precompile at the time of publishing

This will prevent the web.debug.config / web.release.config file from running the web.config file if you are using Visual Studio Publishing.

0
Feb 13 '16 at 21:18
source share



All Articles