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

前端 未结 11 601
鱼传尺愫
鱼传尺愫 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:27

    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

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

    I have seen this too. Specifically, it had been reproducible when changing between build configurations in Visual Studio.

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

    Seemingly the config transforms was just swallowing up an exception when trying to perform the transformation.

    Fixed up my web.config to be valid, and all is working as expected now.

    Hope this helps someone

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

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

    Just copy-paste this snippet into 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 will automate the process of cleaning 'obj' folder using Build Targets.

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

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

    Your transform will still work - and so will your website.

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

    I resolve my conflict by doing the same thing that Job said. Removing the attribute

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

    From the main Web.config and leave it into the Web.debug.config and Web.release.config

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

    I've found this works 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 build(s) complain about edmxResourcesToEmbed disappearing.

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