.NET Bootstrap 无需设置
我有一个 .NET WinForms 应用程序,需要从 CD 运行。 我需要弄清楚用户是否安装了所需的 .NET 版本,或者在必要时安装,而不是在安装后运行应用程序。 我发现的有关引导的任何信息都涉及应用程序的设置和安装。 如果我不安装任何东西,我该如何做到这一点? 我希望有任何信息..
I have a .NET WinForms application which needs to be run from CD. What I need to figure out is if user has required .NET version installed or install if necessary than run the application after installation. Any info I've found about bootstrapping involves setup and installation of the application. How can I do this if I don't install anything? I'd appeciate any info..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我还以为如果不制作安装程序很长时间就无法做到这一点,但事实并非如此。
有一个名为 "GenerateBootstrapper" 的 msbuild 操作。
如果您在 Visual Studio 中:
然后您可以以不同的方式添加“GenerateBootstrapper”操作(取决于您要安装的内容)。MSDN 给出了 .NET 2.0 的示例:
我没有不要尝试这个示例,但我尝试了自己的示例,我可以告诉您,为了在 XP 计算机上安装 .NET 4 Client Profile(这是今天最新的稳定 .NET 版本),您需要安装 Windows 成像组件 这就是为什么首先使用标准 .NET4 客户端。 VS2010 中包含的配置文件先决条件在 XP 上失败,所以我写了 我自己的引导程序。
您可以下载我的示例 VS2010 解决方案,它为控制台应用程序创建引导程序。
但它要求您安装(只需复制)我的引导程序。 步骤如下:
I was also thinking that you can't do it without making an installer for a long time, but that's not true.
There is a msbuild action, called "GenerateBootstrapper".
If you're in Visual Studio:
Then you can add GenerateBootstrapper action in different ways (depend on what you want to install). MSDN gives an example for .NET 2.0:
I didn't try this example, but I tried my own and I can tell you, that in order to install .NET 4 Client Profile (which is the latest stable .NET release for today) on XP machines, you need to install Windows Imaging Component first. That's why standard .NET4 Client Profile prerequisite, included in VS2010, fails on XP. So i wrote my own bootstrapper.
You can download my sample VS2010 solution, that creates a bootstrapper for console app.
But it requires you to install (just copy) my bootstrapper. So here are the steps:
使用 Visual Studio 构建的 msi 安装程序可以包含本机 setup.exe,用于检查框架依赖性并在需要时首先启动安装程序。 您甚至可以将可再发行版本包含在您的 CD 上。 但您必须安装该程序才能使其正常工作。
否则,您必须构建自己的本机代码工具。
The msi installer you build with visual studio can include a native setup.exe that checks the framework dependency and kicks off the installer first if needed. You can even include the redistributable on your cd. But you have to install the program for that to work.
Otherwise, you must build your own native code tool.
您可以编写一个小型本机代码加载器来检查 .NET 运行时,在必要时触发 .NET 安装,然后启动 .NET 应用程序。
You could code a small native code loader that checks for .NET runtime, triggers the installation of .NET if necessary, and then starts your .NET application.
最直接的方法是检查此问题中列出的注册表项:
.Net Framework 检测
脚本文件可能是从 CD 进行检查的最简单方法:
Windows 脚本宿主 - RegRead 方法
Most straightforward way would be to check for registry entries as listed in this question:
.Net Framework detection
A script file might be the easiest way to check from the CD:
Windows Script Host - RegRead method