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

前端 未结 11 602
鱼传尺愫
鱼传尺愫 2020-12-08 03:55

I\'m getting this strange intermitent bug in a MVC 3.0 project When I build the project sometimes I get the following error message:

Unrecognized attr

相关标签:
11条回答
  • 2020-12-08 04:35

    I ran into the very same problem. You will find lots of banter out there related to MvcBuildViews and various error conditions. But none seem to mention this particular error. A quick fix that worked for me was to delete the contents of the "obj" directory for the affected web project, then rebuild.

    0 讨论(0)
  • 2020-12-08 04:51
    1. Right click on the project, click Publish
    2. Goto Settings -> File Publish Options
    3. Uncheck Precompile during publishing

    This will prevent the web.debug.config/web.release.config injecting the file back to the web.config if you are using visual studio publish.

    0 讨论(0)
  • 2020-12-08 04:52

    This works with Continuous Integration and WebDeploy:

    This problem occurs the moment I set

    <MvcBuildViews>true</MvcBuildViews>
    

    in my Project file, which I need to do.

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

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

    You (only) need to delete the TransformWebConfig subfolder in your buildfolder during the pre- AND post-build events. It even works with continuous integration servers which break if no folder exists

    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 fine with Resharper which will sometimes get confused, if you delete the whole obj folder.

    Make sure to set the Run the post-build event to always!!

    UPDATE: Replaced debug and release with $(ConfigurationName) and removed resulting duplicate line

    0 讨论(0)
  • 2020-12-08 04:52

    I just change below on web.config

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

    to

    <configuration>
    

    It fixed the problem

    0 讨论(0)
  • 2020-12-08 04:53

    I've also run into this issue. For me it was caused by my having created a new debug configuration called, "DevDebug". I fixed it by making a copy the web.debug.config, named web.DevDebug.config and added it to the project.

    Then, when I attempted to run the aspnet compiler, it was satisfied that it could find the right configuration version of the config file to merge in.

    0 讨论(0)
提交回复
热议问题