使用msbuild编译时间mvc视图检查

And*_*ock 15 msbuild asp.net-mvc

我发现在ASP.NET MVC项目的.csproj中有以下目标:

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

这将检查.csproj中的MvcBuildViews bool属性,如果设置为true,则获取构建以检查视图.

我使用NAnt来构建我的应用程序以进行部署,是否可以从msbuild命令行运行此目标而无需修改csproj?(我希望它只在部署时运行,而不是每个构建都运行,因为它的慢速+ resharper无论如何都会在VS中捕获它)

如果没有,如何将上述代码翻译成msbuild命令行,以便我可以修改我的部署脚本?这是我当前的脚本:

<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>
Run Code Online (Sandbox Code Playgroud)

Jul*_*rau 17

将属性MvcBuildViews设置为true应该有效.

<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>
Run Code Online (Sandbox Code Playgroud)