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
Why Cannot Ienumerable<Struct> Be Cast as Ienumerable<Object>
How Does Startcoroutine/Yield Return Pattern Really Work in Unity
Entity Framework 6: Audit/Track Changes
Automatic Native and Managed Dlls Extracting from Nuget Package
Xmlwriter to Write to a String Instead of to a File
Unit Testing and Checking Private Variable Value
How to Add an Event to a Usercontrol in C#
Save Settings in a .Net Winforms Application
ASP.NET Core API Only Returning First Result of List
How to Set System Environment Variable in C#
How to Ensure All Data Has Been Physically Written to Disk
Better Way to Trigger Onpropertychanged
Why Won't Control Update/Refresh Mid-Process
Control Cannot Fall Through from One Case Label
ASP.NET Core 3.0 System.Text.JSON Camel Case Serialization
C# Picturebox Transparent Background Doesn't Seem to Work
Why Enums Require an Explicit Cast to Int Type
Serialize Property, But Do Not Deserialize Property in JSON.Net