在Azure Web App上预编译ASP.NET MVC视图 [英] Precompile ASP.NET MVC views on Azure Web App

查看:69
本文介绍了在Azure Web App上预编译ASP.NET MVC视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以预编译Azure Web App上的ASP.NET MVC视图(特别是通过VSTS上的发布管理发布时)?

Is there a way to precompile the ASP.NET MVC views on an Azure Web App (specifically when published via Release Management on VSTS)?

一旦每个视图被点击一次,页面随后就会非常快速地呈现.但是对于用户来说,第一次延迟可能是个麻烦,而且无法编写脚本来触摸每个页面.

Once each view has been hit once, the page subsequently renders very quickly. But that first delay can be a doozy for users and there's no way to script touching each page.

我不确定是否需要在VSTS的构建/发布过程中进行某些更改(我正在使用Visual Studio Build构建步骤和Azure Web App发布任务),或者是否需要在Azure上运行某些内容发布(或完全其他)后的Web App实例.

I'm not sure if I need to change something in the build/release processes on VSTS (I am using the Visual Studio Build build step and the Azure Web App release task) or if I need to run something on the Azure Web App instance after it is released (or something else altogether).

似乎在发布后找到了某种方法来调用aspnet_compiler可能是我所需要的(而且我已经看到了有关Cloud Services上的Web角色的信息),但我无法使其正常工作.

It seems like finding some way to call aspnet_compiler after publish might be what I need (and I have seen that in reference to Web Roles on Cloud Services) but I can't get that to work.

呼叫

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler -v "/" -p "d:\home\site\wwwroot" 

通过Azure门户中的控制台

可以很好地执行(并且发现错误,如果有的话),但是对启动时间没有任何影响-第一次击中视图仍然需要很长时间.

via the Console in the Azure Portal executes just fine (and finds errors if there are any) but doesn't have any impact on startup time - hitting a view the first time still takes a long time.

所以也许这不是正确的方向.

So maybe that isn't the right direction.

我查看了RazorGenerator(包括.MSBuild nuget包),但无法完全正常工作,但实际上我很犹豫是否要对项目进行如此多的更改,以便在发布时进行预编译.

I've looked at RazorGenerator (including the .MSBuild nuget package) and I couldn't quite get it to work, but really I was hesitant to make so many changes to the projects just to get precompilation on release.

还请注意,我目前在VSTS中使用的是TFVC,而不是Git,因此据我所知,Kudu/Git集成(根据某些文章似乎确实触发了预编译)不可用.

Also note that I am currently using TFVC, not Git, in VSTS, so the Kudu/Git integration (that does seem to trigger the precompilation according to some articles) isn't available to me as far as I can tell.

其他想法?

推荐答案

您可以在"Visual Studio Build"步骤中添加"/p:PrecompileBeforePublish = true"参数:

You can add "/p:PrecompileBeforePublish=true" argument in "Visual Studio Build" step:

然后,该任务将在构建过程中调用aspnet_compiler并生成预编译的输出以进行部署.

Then the task will call aspnet_compiler during the build process and generate a precompiled output for deployment.

这篇关于在Azure Web App上预编译ASP.NET MVC视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆