views:

500

answers:

1

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>
+3  A: 

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>
madgnome
Brilliant, I didn't know you could do that, but then looking at my own script I'm clearly already doing it for a several other properties! doh!
Andrew Bullock