Web.config转换:未声明转换属性

Jon*_*ood 16 web-config visual-studio web.config-transform

我正在尝试转换我的Web.config文件以添加发布版本的重写规则,但我收到了一个intellisense错误.

未声明" http://schemas.microsoft.com/XML-Document-Transform:Transform "属性.

Web.Release.config

Web.Release.config

似乎没有错误编译好.但是当我尝试发布时,我确实遇到了构建错误:

源文档中的任何元素都不匹配'/configuration/system.webServer/rewrite' 未声明
' http://schemas.microsoft.com/XML-Document-Transform:Transform '属性.

上面的第一行是错误,而第二行是警告.为什么这不起作用?

请注意,我的Web.config顶部确实包含该行<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

更新:

部署时的构建错误原因是由其他原因引起的.所以,事实上,它确实构建好,我可以部署.所以在这一点上,问题只是为什么出现这个Intellisense错误/警告.

Phi*_*hil 17

我在VS 2013中为transform .config中的<rewrite>启用IntelliSense中的建议这是Intellisense的一个缺陷.如果你正在使用VS 2017打开"C:\ Program Files(x86)\ Microsoft Visual Studio\2017\Enterprise\Xml\Schemas\1033\DotNetConfig.xsd".在文件末尾附近找到重写元素并复制<xs:anyAttribute namespace="http://schemas.microsoft.com/XML-Document-Transform" processContents="strict"/>到重写元素的末尾.一旦我保存文件Visual Studio删除警告波浪形.

在此输入图像描述

有人应该在Visual Studio团队中提出这个问题.

  • 我通过Visual Studio Feedback提出了这个问题.https://developercommunity.visualstudio.com/content/problem/67412/intellisense-issue-rewrite-transform.html (4认同)
  • 在VS 2019中似乎仍然会发生这种情况,但该修复程序无法修复它。 (3认同)