我试图转换我的 Web.config 文件,为发布版本添加重写规则,但是我遇到了 IntelliSense 错误。
'http://schemas.microsoft.com/XML-Document-Transform:Transform' 属性未声明。
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 错误/警告。
rewrite
之前使用<add xdt:Transform="RemoveAll" />
吗?否则,进入XML菜单
,选择schemas
并查找DotNetConfig.xsd
,然后选择使用此模式。如果仍然无法正常工作,您还可以尝试选择RazorCustomSchema.xsd
和EntityFrameworkConfig_6_1_0.xsd
模式。如果现在仍然无法正常工作,请在配置中将链接设置为:xmlns="http://schemas.microsoft.com/XML-Document-Transform"
。此外,如果您在浏览器中使用该链接,则会看到“您正在查找的资源已被删除、名称已更改或暂时不可用。”。 - King Reloadconfiguration
中添加<configSections>
和<connectionStrings>
。 - King Reload