在Azure Web服务发布期间进行预编译 [英] Precompile during publish for Azure Web Services

查看:161
本文介绍了在Azure Web服务发布期间进行预编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用 Azure Web服务 不是网站),并在其中运行ASP.Net MVC 5.1应用程序。

We are using Azure Web Services (not Web-sites) and run ASP.Net MVC 5.1 application inside it.

当我通过Web部署发布网站时,我可以选择在发布时预编译:

When I publish web-sites through Web-deploy, I have an option to "Precompile during publishing":

发布时到Azure Web服务,我无法在任何地方找到这个选项。任何指针?

When I publish to Azure Web Services, I can't find this option anywhere. Any pointers?

这个想法是预先编译视图,所以首先点击一个视图不会因为编译而被时间处罚。

The idea is to pre-compile views, so first hit to a view would not be time-penalised by compiling on the fly.

我看过剃刀发生器,但它不符合我们的需要。我看到很少的其他选择,但在出版阶段编辑观点对我们来说是最有意义的。

I've looked on Razor Generator but it does not suit our needs. I've seen few other options, but compiling views at publishing stage makes the most sense for our case.

UPD:
仅供参考,我曾尝试过 David Ebbo建议它没有工作

推荐答案

调用编译器%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -m / LM / Azure服务器上的命令行中的W3SVC / 1273337584 / ROOT 似乎导致编译。临时ASP.Net根目录包含一个目录,这个目录的大小和文件数量将增加。然后,该站点在编译后重新启动。第一页打开性能好像好多了。

Calling compiler %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -m /LM/W3SVC/1273337584/ROOT from command line on the Azure server seems to cause compilation. The Temporary ASP.Net root directory contains one directory this increases in-size and number of files contained within. The site then restarts after compilation. First page open performance then seems much better.

如果我在一个启动脚本中运行它,它不起作用,因为该站点是不可用的。我猜IIS还没有启动。看看做这样的事情 Azure:如何执行启动任务延迟?

If I run this within a startup script it doesn't work as the site isn't avaible. I guess IIS hasn't started up. Looking at doing something like this Azure: How to execute a startup task delayed?

对于不同的部署,站点ID似乎没有变化。我想可以从IIS中获取站点ID,然后使用它。如果是这样的话。

The site ID doesn't seem to change for different deployments. I guess could get the site id out of IIS and then use that it if it does.

所以看起来像这样。有更优雅的方式吗?不明白为什么编译和部署视图文件是这样的烦恼。

So looks like that does it. Is there are more elegant way? Don't understand why compiling and deploying view files is such a chore.

这篇关于在Azure Web服务发布期间进行预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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