我发现在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>
原文地址:https://www.jb51.cc/aspnet/250345.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。