Mvcbuildviews Not Working Correctly

MVCBuildViews not working correctly

I had this problem a few days ago and I fixed it by deleting obj/Debug folder. Cleaning the project also works. I have no idea about the cause of the issue, though.

See Joe Cartano's answer for a more permanent solution.

VS2013 does not compile ASP.NET MVC5 views

Does your project include the target and hook into after build event? Try msbuild WebApplication1.csproj /t:MvcBuildViews from command line, it'll check that you have both default property set and target defined.

<PropertyGroup>
<MvcBuildViews>true</MvcBuildViews>
</PropertyGroup>

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

Try creating a blank MVC project from within the VS2013U4 and compare the csproj to yours.

Why won't my ASP MVC Views build the second time round

So, the ACTUAL problem was in my project file I had this:

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

Deleted it, and I could recompile no problem.

Does MvcBuildViews actually do anything?

When <MvcBuildViews> is set to true, building the web project results in errors if the views contain any server-side code issues. Note that this includes C# errors (compile-time / type-safety / etc.), but not JavaScript errors, as those are intrinsically non-compiled.

This feature works for Razor and WebForms views, but it seems to have no effect when the Spark view engine is being used.

MVC3 Strange error after switching on compilation of views

I have tried a lot of different solutions available in the web, but either they did not quite fit onto my problem, or they did not work.

To recap my problem:

After switching CompileViews on, I immediately got the above error during compile.
I am using the default Visual Studio Development Server of VS2010 to test my MVC app.

Today I opened a request at Microsoft Developer support, and - I am almost ashamed to admit it - got my answer approximately 30 seconds into the callback from the technician:

All he said was: Please goto your obj folder and delete all contents. Then compile again.

And that really was all it took.

So after a lot of head-shaking about myself I wanted to share the results with you.



Related Topics



Leave a reply



Submit