MVC View Compilation

To generate views’ code during compilation of ASP .NET MVC 2 application, its project file (*.csproj) should contain next (the rest has been omitted):

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
      <MvcBuildViews>true</MvcBuildViews>
  </PropertyGroup>
  <Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" />
  </Target>
</Project>

MvcBuildViews of the top most PropertyGroup should equal true and the AfterBuild target should invoke AspNetCompiler

Advertisements
This entry was posted in .NET, ASP .NET MVC, C#. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s