Friday, March 18, 2011

ASP.NET MVC & MvcBuildViews set to true causes Build Error

I recently set the property in my ASP.NET MVC web application for the Release mode as recommended by K. Scott Allen in Notes on Building Razor Views. This was working fine for a few days. Then yesterday, I started getting this error every time I would try a Release build.

It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

I went back to the comments from the blog post and found this one, where someone else was having the same issue and they solved the issue by deleting the obj\ folder, as recommended by the StackOverflow MVC BuildViews not working correctly question. I tried this and unfortunately it did not resolve my issue. Another answer further down suggested changing the PhysicalPath value for the AspNetCompiler value in the BuildViews task. I tried the recommended path:



That also did not work for me, so I followed a link to the use of Web Deployment Projects with ASP.NET MVC and noticed that they were using the following PhysicalPath setting.



I changed my setting to this value, $(ProjectDir)\..\Web created this directory and now things are working properly again.

1 comment:

Como saber si estoy en ASNEF said...

Just wish to say your article is as astounding. The clearness in your submit is simply great and that i can think you’re an expert on this subject. Well together with your permission allow me to clutch your RSS feed to keep updated with approaching post. Thank you a million and please keep up the gratifying work.