加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 编译时mvc视图检查与msbuild

发布时间:2020-12-15 23:25:35 所属栏目:asp.Net 来源:网络整理
导读:我发现在ASP.NET MVC项目的.csproj中有以下目标: Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'" AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)..$(ProjectName)" //Target 这将检查.csproj中的MvcBuildViews bool
我发现在ASP.NET MVC项目的.csproj中有以下目标:
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)..$(ProjectName)" />
</Target>

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

我使用NAnt构建我的应用程序进行部署,是否可以让这个目标从msbuild命令行运行而不必修改csproj? (我希望它仅在部署时运行,而不是每个构建,因为它的慢速重新加载器在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>

解决方法

将属性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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读