Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compile time mvc view checking with msbuild

I've found that in the .csproj for an ASP.NET MVC project there is the following target:

<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
</Target>

This examines the MvcBuildViews bool property in the .csproj which if set to true gets the build to check the views.

I use NAnt to build my app for deployment, is it possible to get this target to run from the msbuild command line without having to modify the csproj? (I want it to be run only on deploy, not every build as its slow + resharper catches it in VS anyway)

If not, how to i translate the above code to msbuild command line so i can modify my deploy script? Here's my current script:

<target name="Deploy" depends="init">
    <exec basedir="." program="${DotNetPath}msbuild.exe" commandline=" src/MyProject.Web/MyProject.Web.csproj /nologo 
  /t:Rebuild
  /t:ResolveReferences;_CopyWebApplication
  /p:OutDir=../../output/build/bin/
  /p:WebProjectOutputDir=../../output/build/
  /p:Debug=false
  /p:Configuration=Release
  /v:m"
    workingdir="." failonerror="true" />
    <call target="tests"/>
    <call target="compress-js"/>
    <call target="compress-css"/>
    <call target="rar-deployed-code"/>
  </target>
like image 691
Andrew Bullock Avatar asked Mar 16 '09 10:03

Andrew Bullock


1 Answers

Setting the property MvcBuildViews to true should work.

<target name="Deploy" depends="init">
  <exec basedir="." program="${DotNetPath}msbuild.exe" commandline=" src/MyProject.Web/MyProject.Web.csproj /nologo 
    /t:Rebuild
    /t:ResolveReferences;_CopyWebApplication
    /p:OutDir=../../output/build/bin/
    /p:WebProjectOutputDir=../../output/build/
    /p:Debug=false
    /p:Configuration=Release
    /p:MvcBuildViews=true
    /v:m"
      workingdir="." failonerror="true" />
      <call target="tests"/>
      <call target="compress-js"/>
      <call target="compress-css"/>
      <call target="rar-deployed-code"/>
</target>
like image 181
Julien Hoarau Avatar answered Oct 21 '22 00:10

Julien Hoarau