18

I am attempting to transform my Web.config file to add rewrite rules for release builds, but I'm getting an intellisense error.

The 'http://schemas.microsoft.com/XML-Document-Transform:Transform' attribute is not declared.

Web.Release.config

Web.Release.config

It seems to compile okay without errors. But when I attempt to Publish, I do get build errors:

No element in the source document matches '/configuration/system.webServer/rewrite'
The 'http://schemas.microsoft.com/XML-Document-Transform:Transform' attribute is not declared.

The first line above is an error, while the second one is a warning. Why doesn't this work?

Note that the top of my Web.config does include the line <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

UPDATE:

The build error when deploying turned out to be caused by something else. So, in fact, it does build okay and I can deploy. So at this point, the question is just about why this Intellisense error/warning is appearing.

Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
  • have you tried to `` before you do the `rewrite`? Else go to the `XML menu` choose `schemas` and find for `DotNetConfig.xsd` and choose use this schema. If this still doesn't work you could also try selecting the `RazorCustomSchema.xsd` and `EntityFrameworkConfig_6_1_0.xsd` schemas. If now it doesn't work, set in configuration the link as: `xmlns="http://schemas.microsoft.com/XML-Document-Transform"`. Also if you use that link in the broswer you can see `The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.` – King Reload Jun 07 '17 at 13:22
  • Hi @Jonathan. I'm afraid I don't have an answer, but it seems this question has been asked before. https://stackoverflow.com/questions/24059257/how-do-i-enable-intellisense-in-vs-2013-for-rewrite-in-transform-config – Rob Jun 07 '17 at 13:53
  • You could also try adding `` to the `configuration` and also `` – King Reload Jun 07 '17 at 14:26
  • Appears to be a defect in Intellisense. See https://stackoverflow.com/questions/24059257/how-do-i-enable-intellisense-in-vs-2013-for-rewrite-in-transform-config – Phil Jun 11 '17 at 14:38
  • @Jonathan Wood: For me it cannot be published (VS2019). I am getting "namespace prefix xdt is not defined", how did you solve this? – Muflix Feb 01 '21 at 18:50
  • @Muflix: Nothing to solve. It's an issue with Intellisense. Aside from the red squigglies, it still works as intended. – Jonathan Wood Feb 01 '21 at 19:15
  • @Jonathan Wood I was able to build, but not able to publish the project via the publish wizard (the publish process stopped because of this error). But in the end I finally solved my issue with this approach https://stackoverflow.com/a/36836533/2333663 – Muflix Feb 01 '21 at 20:04

1 Answers1

21

As suggested in How do I enable IntelliSense in VS 2013 for <rewrite> in transform .config? this is a defect in Intellisense.

  • If you're using VS 2017 open "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Xml\Schemas\1033\DotNetConfig.xsd".

  • Locate the xs:element name="rewrite" element near the end of the file and copy

    <xs:anyAttribute namespace="http://schemas.microsoft.com/XML-Document-Transform" processContents="strict"/>
    

    to the end of the rewrite element.

As soon as I saved the file Visual Studio removed the warning squiggly.

enter image description here

Someone should probably raise this with the Visual Studio team.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Phil
  • 42,255
  • 9
  • 100
  • 100