MVCBuildViews are not working properly

So, I edited the csproj file in an RTM MVC 3 application to set the following property:

<MvcBuildViews>true</MvcBuildViews> 

This should result in my views being respected during the build and forced to build a build error if my view is broken. This is the only change I made, however, when I try to create an application, I get the following error:

An error occurred while using a section registered as allowDefinition = 'MachineToApplication' that exceeded the application level. This error can be caused by the fact that the virtual directory is not configured as an application in IIS.

The project compiles and succeeds if I return to false,

Listed below are the build tasks configured in the csproj file (they were never manually edited, they were added by Visual Studio 2010)

 <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" /> </Target> 

Am I missing something? How to properly configure MVC 3 / Visual Studio 2010 to check my views during build?

+44
c # asp.net-mvc visual-studio-2010 msbuild
Jan 18 2018-11-18T00:
source share
5 answers

I had this problem a few days ago, and I fixed it by deleting the obj / Debug folder.

Edit: see Joe Cartano's answer for a more permanent solution.

+50
Jan 18 '11 at 18:53
source share
β€” -

This problem occurs when there is a web project output in the obj folder (templated web.config or temporary publishing files). The ASP.NET compiler used is not smart enough to ignore stuff in the obj folder, so instead it generates errors.

Another fix is ​​for nuke to display the publication right before the call to <AspNetCompiler>. Open your .csproj and change this:

 <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" /> </Target> 

:

 <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> <ItemGroup> <ExtraWebConfigs Include="$(BaseIntermediateOutputPath)\**\web.config" /> <ExtraPackageTmp Include="$([System.IO.Directory]::GetDirectories(&quot;$(BaseIntermediateOutputPath)&quot;, &quot;PackageTmp&quot;, System.IO.SearchOption.AllDirectories))" /> </ItemGroup> <Delete Files="@(ExtraWebConfigs)" /> <RemoveDir Directories="@(ExtraPackageTmp)" /> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" /> </Target> 

This will delete all web.configs in \ obj, as well as all PackageTmp folders in \ obj.

+34
Feb 09 '13 at 19:38
source share

When you get this error, do you have another web.config file in your obj folder? If you use MSDeploy, this may help: http://blogs.msdn.com/b/webdevtools/archive/2010/05/14/the-aspnet-compiler-build-task-in-visual-studio-2010-asp -net-mvc-2-projects.aspx , if not, maybe another web.config tool is created by some tool that you use.

+21
Jan 19 '11 at 5:27
source share

This is what worked for me. Optionally, you can specify a condition with a configuration.

 <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" /> </Target> <Target Name="AfterBuild" Condition="'$(Configuration)'!='Debug'"> <RemoveDir Directories="$(BaseIntermediateOutputPath)" /> </Target> 
+2
Jan 08 '14 at 10:01
source share

Try changing this AspNetCompiler line to this:

 <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" /> 
0
Jan 18 2018-11-18T00:
source share



All Articles