预编译 ASP.NET 解决方案以进行部署

发布于 2024-07-26 12:14:21 字数 736 浏览 5 评论 0原文

我正在使用 aspnet_compiler.exe 预编译我的应用程序以进行部署。

但是,我认为它不起作用,有两个原因:

  • 我在 C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files 下看到我的应用程序程序集,即使我手动清除此目录也是如此; 重新启动应用程序。
  • 应用程序的 JIT 性能受到影响。 这是我特别想避免的,即使它是“一次性”。

这就是我正在做的具体事情:

  1. 在工作室中构建解决方案。
  2. 位置
  3. 执行 aspnet_compiler.exe -v /Foo -pc:\builddir c:\deploydir (其中 Foo 是我的应用程序在其下运行的 vdir,c:\builddir 是 studio 构建到的位置,c:\deploydir 是我随后复制的 c:\deploydir 到 Web 服务器。
  4. 我访问 http://localhost/Foo
  5. 30 秒后,应用程序显示,我可以看到程序集已在临时 ASP.NET 文件中生成。

如果值得注意的话,我正在使用 .net 3.5 SP1/Studio 2008 SP1,并且在 web.config 中设置了编译 debug=false。

I'm using aspnet_compiler.exe to precompile my application for deployment.

However, I don't think it's working, for two reasons:

  • I see my applications assemblies under C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files, even if i manually clear out this directory & restart the app.
  • The performance hit to JIT the application is present. This is very specifically what I'd like to avoid, even though it is 'one time'.

Here's specifically what I'm doing:

  1. Build the solution in studio.
  2. execute aspnet_compiler.exe -v /Foo -p c:\builddir c:\deploydir (where Foo is the vdir my app runs under, c:\builddir is where studio builds to, and c:\deploydir is the location where
  3. I then copy c:\deploydir to the web server.
  4. I access http://localhost/Foo
  5. After 30 seconds, the app displays, and I can see that assemblies have been generated in Temporary ASP.NET Files.

If it's notable, I'm using .net 3.5 SP1/Studio 2008 SP1. compilation debug=false is also set in web.config.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

极致的悲 2024-08-02 12:14:21

您的两点没有实际意义:

  1. ASP.NET 预编译不会导致本机映像生成,因此 JIT 开销仍然存在。 还可能存在工作进程创建开销。

  2. ASP.NET 预编译可以选择编译所有内容(包括 ASPX 内容等)或仅编译源代码(您可以使用 -u 开关指定)。 对于后者,仍将为 ASPX 文件生成这些程序集。 对于前者,您看到的不是程序集生成。 运行时只是将程序集复制并缓存在 临时 ASP.NET 文件 中的 /bin 中。 您可以通过逐字节比较程序集并查看它们是否相同来确认这一事实。

Your two points are moot:

  1. ASP.NET precompilation doesn't result in native image generation so JIT overhead will still be there. There might be a worker process creation overhead too.

  2. ASP.NET precompilation has the option to compile everything (incl. ASPX stuff, ...) or just source code (which you can specify with the -u switch). In case of the latter, those assemblies will still be generated for ASPX files. In case of the former, what you are seeing is not assembly generation. The runtime just copies and caches the assemblies in /bin in Temporary ASP.NET Files. You can confirm this fact by comparing the assemblies byte by byte and see that they are identical.

云裳 2024-08-02 12:14:21

使用 aspnet_compiler.exe 预编译网站不会 JIT 编译代码 - 您需要 ngen 执行此操作的代码。

本机图像生成器 (Ngen.exe)
是一个改善的工具
托管应用程序的性能。
Ngen.exe 创建本机映像,
是包含已编译的文件
处理器特定的机器代码,以及
将它们安装到本机映像中
缓存在本地计算机上。 这
运行时可以使用来自
缓存而不是使用即时
(JIT)编译器编译原始文件
组装。

Precompiling the website with aspnet_compiler.exe doesn't JIT compile the code - you would need to ngen the code to do that.

The Native Image Generator (Ngen.exe)
is a tool that improves the
performance of managed applications.
Ngen.exe creates native images, which
are files containing compiled
processor-specific machine code, and
installs them into the native image
cache on the local computer. The
runtime can use native images from the
cache instead using the just-in-time
(JIT) compiler to compile the original
assembly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文