从 NSIS 安装程序调用 ngen

发布于 2024-08-25 18:10:29 字数 243 浏览 4 评论 0原文

我正在使用 NSIS 部署 .Net 应用程序。安装/卸载过程工作正常,但我想添加最后的 ngen 步骤以提高启动性能。

遗憾的是,谷歌并未透露任何相关材料。以前不太可能没有人这样做过——也许这里有人有一些想法?

在不太可能的情况下,如果没有丑陋的黑客攻击就无法支持,我愿意使用不同的安装程序技术只要它可以在我的 Linux 构建服务器上运行。 (例如,这排除了 WiX。)

有什么想法吗?

I am using NSIS to deploy a .Net application. The installation/uninstallation process works fine, but I would like to add a final ngen step to improve startup performance.

Unfortunately, Google didn't reveal any relevant material. It's unlikely that noone has ever done this before - maybe someone here has some idea?

In the unlikely case that this is impossible to support without ugly hacks, I would be willing to use a different installer technology provided it can run on my Linux build server. (This rules out WiX, for example.)

Any ideas?

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

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

发布评论

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

评论(3

静若繁花 2024-09-01 18:10:29

NGen 将位于 .NET Framework 目录中,例如:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

选项 1 - GetCORSystemDirectory() 是一个系统 API 调用,您可以使用它来获取.NET Framework 的目录,但这里的问题是,从阅读文档看来,它需要从 .NET 应用程序中调用。因此,您可以运行一个小型 .NET 应用程序,并将 GetCORSystemDirectory() 的结果写入 ini 文件。也许搜索该功能,看看是否可以通过谷歌找到任何有用的东西。

选项 2 - 您可以假设 .NET 框架位于预期路径中,并迭代目录并找到以“v2.0.”开头的目录。

选项 3 - 只需从安装程序中提取 ngen,然后运行它。这就是我有时在重高潮时所做的事情。我不确定您可能会遇到什么副作用,这是否完全合法,或者是否有它依赖的任何其他文件。如果它是类似 regasm.exe 的东西,只要已经安装了 .NET 框架就应该没问题。

NGen will be in the .NET framework directory such as:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

Option 1 - GetCORSystemDirectory() is a sytem API call that you can use to get the directory of the .NET Framework, but the problem here is that it sounds like from reading the documentation that it needs to be called from a .NET application. So you could run a tiny .NET application and have it write the result of GetCORSystemDirectory() to a ini file. Maybe search for that function and see if you find anything useful through google.

Option 2 - You could assume the .NET framework in in the expected path and iterate through the directorys and find one that starts with "v2.0.".

Option 3 - Simply extract ngen from your isntaller and then run it. This is what I've done with regasm on occasion. I'm not sure what side effects you might encounter, whether this is completely legal, or if there are any other files it depends on. If it's anything like regasm.exe, you should be fine as long as the .NET framework is already installed.

柠檬色的秋千 2024-09-01 18:10:29

您可以使用内置的 Exec/ExecWait 命令在最后一节中执行 ngen (或者,使用 nsExec 或第 3 方 exec 插件之一)

ExecWait '"ngen.exe" install "c:\path\to\your\assembly" /silent'

注意:这假设 ngen 位于路径或当前目录中,而它可能不在大多数路径或当前目录中系统,因此要么使用 SetOutPath 设置当前目录,要么使用 ngen 的完整路径。

您必须自己找出所需的确切开关,请参阅 MSDN 的 2.01.x ngen 文档

You could execute ngen in your last section using the built in Exec/ExecWait commands (Alternatively, use nsExec or one of the 3rd party exec plugins)

ExecWait '"ngen.exe" install "c:\path\to\your\assembly" /silent'

Note: this assumes that ngen is in the path or current directory which it probably is not on most systems, so either set the current directory with SetOutPath or use a full path to ngen

You have to figure out the exact switches you need on your own, see MSDN for 2.0 and 1.x ngen documentation

独行侠 2024-09-01 18:10:29

似乎有一种方法可以通过nsis获取运行时目录: http://nsis.sourceforge.net/Get_directory_of_installed_ .NET_runtime

一旦知道了路径,剩下的就是使用正确的参数调用 ngen 了。伟大的!

Seems there is a way to get the runtime directory through nsis: http://nsis.sourceforge.net/Get_directory_of_installed_.NET_runtime

Once the path is known, all that's left is calling ngen with the correct parameters. Great!

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