Windows Installer在Win 10上失败,但在使用WIX的Win 7上失败 [英] Windows Installer fails on Win 10 but not Win 7 using WIX

查看:110
本文介绍了Windows Installer在Win 10上失败,但在使用WIX的Win 7上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近被分配更新我们的项目安装程序以在Windows 10上运行,而我对如何使其工作不知所措.我没有安装程序的经验,并且不仅要熟悉整个过程,而且要熟悉我们的项目如何处理它.

到目前为止,该安装程序可以在Windows 7 VM上完美运行,但是在Windows 10 VM上运行时,安装将在接近尾声时失败并开始回滚.我已经得到它吐出了一些日志文件,我正在仔细研究它们,但损失相当大.

我已经找到了这一点:

MSI (s) (B0:F4) [17:39:02:883]: Note: 1: 1708 
MSI (s) (B0:F4) [17:39:02:883]: Note: 1: 2205 2:  3: Error 
MSI (s) (B0:F4) [17:39:02:883]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1708 
MSI (s) (B0:F4) [17:39:02:883]: Note: 1: 2205 2:  3: Error 
MSI (s) (B0:F4) [17:39:02:883]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709 
MSI (s) (B0:F4) [17:39:02:883]: Product: GPEP -- Installation failed.

在安装程序似乎失败时或附近发生的末尾.

下一行在末尾有这个:

Installation success or error status: 1603.

我调查了错误并发现了这个问题:解决方案

将此添加为答案-注释太长,我认为这也是正确的答案.如果您阅读此答案,请也从上方


答案

依赖于缺少的运行时(如Powershell)肯定会触发回滚. MSI为某些脚本自定义操作(活动脚本)托管自己的运行时.例如VBScript和JavaScript.为了可靠地进行部署,建议所有使用的自定义操作要么是自包含的最低依赖性C ++ dll或可执行文件(win32),要么是(不太理想的)VBScript或JavaScript(如果使用Installshield,甚至是Installscript-请参见下面的详细信息). /p>

我的有争议的意见 :用于可靠性和健壮性的最差的自定义操作是需要特定版本的.NET框架的.NET二进制文件.这也适用于PowerShell-它不仅是托管代码,而且还是脚本.我很想说这些技术不应该用于部署,但是如果您需要使用PowerShell,则必须至少在安装开始时添加一个验证已安装PowerShell"自定义操作,并以如果PowerShell不可用,则会显示(和/或记录)正确的错误消息.

这是真实答案的结尾:-).如果您要制作一个用于一般发行的软件包(而不仅仅是您自己公司内部部署的软件包),则下面是一些冗长的沉思".如果我是您,即使您仅在内部进行部署,我也会阅读它, PowerShell自定义操作可能会成为酝酿成规模的部署问题.

托管代码和脚本均存在问题. PowerShell实际上是同时存在的. 这是Rob Mensching的博客关于脚本自定义操作为什么不好的原因.本质上:脚本易碎,缺少语言功能,难以调试,并且防病毒产品经常将其阻止.阅读博客.并且 意见警告 :但是,总体而言,.NET二进制文件和PowerShell脚本是最不可靠的自定义操作.我永远不会将它们用于针对各种计算机的设置.

如果您要制作 MSI以便将其常规分发到任何地方的任何计算机上,我将花一些时间将PowerShell脚本转换为其他脚本.最好是C ++ dll-我认为这是最可靠的.没有要说的依赖项或要依赖的层.如果您一直使用Installshield,则即使InstallScript也可以接受(此时它可以在没有预装运行时的情况下运行-大大提高了其可靠性和实用性-尽管它是一种陈旧的语法,但它是一种晦涩的语言.被低估了-它可以完成工作,并且比C ++更简单.

JavaScript VBScript 自定义操作甚至可以用于一般分发到任何计算机的MSI,但仍然可以使用不推荐.我倾向于只将它们用于内部公司部署"软件包.这些可以标准化,并且至关重要的是脚本对其他系统管理员和打包程序透明.他们可以查看并检查安装过程中正在执行的操作.这通常是可取的,并且 MSI对企业的主要好处之一部署,但有时您需要编译的二进制文件来隐藏实施详细信息(例如,在验证许可证密钥时).这样就不能使用任何类型的脚本-显然.通过透明并嵌入到MSI中(因此始终可以获取完整的运行源代码),它可以帮助不同的应用程序包装商在需要时接管其他人的工作.在部署团队中,总会有人来调试脚本-但是很少有人会知道正确的C ++.在内部应用程序开发人员在没有太多部署知识的情况下制作自己的MSI文件的公司中,脚本可能会完全误入歧途,并导致非常困难的部署问题.通常,需要对应用程序本身进行小的更改以允许更可靠的部署.例如,应用程序应该执行自己的启动配置-这些操作都不应该在安装脚本中完成,但是许多开发人员都可以这样做.

使用脚本自定义操作是有争议的.如果您询问2位开发专家,您将获得4条意见.在我看来,白框"自定义操作(脚本)如果用于执行某些不常见的特定操作,则非常适合公司使用,以便人们可以看到发生了什么.对于始终需要的内容,公司应在MSI文件中创建由自定义表驱动的经过编译的C ++ dll,并提供完整的质量检查和回滚支持-所有脚本自定义操作通常都缺少这种东西(实行). 数据驱动"(定制表)C ++定制操作具有最大的优势,即具有最小的依赖性,并且也是透明的(将发生的事情是透明的,但是实际的实现被编译和隐藏了,这也可以提高安全性). WiX工具包提供了这样的自定义操作dll,并以C ++编写了回滚支持.它应该可以解决企业部署所需的大多数自定义任务.尽管所有这些都超出了您的问题-只是题外话:-).


如果我猜想我会说Windows Installer可能已更新为能够托管Powershell自己的运行时-但这只是猜测.我不确定技术细节-似乎需要整个.NET运行时?如果您问我,我仍然会更喜欢JavaScript而不是PowerShell脚本,但是我知道您可能致力于将PowerShell作为公司标准?另外, 总是比JavaScript更喜欢VB脚本 ,因为它看起来像异常处理(VB Script完全缺少). 更新:实际测试表明,与Javascript相比,VBScript实际上更适合与MSI一起使用.例如:使用Javascript访问 MSI API 时,出现了一些难以理解的问题.创建MSI时,使用VBScript进行的测试可能比使用Javascript进行的测试更多.老实说:这两种语言"都有严格的限制,而且都很难调试.

Rob Mensching Chris Painter Phil Wilson Bob Arnson ,也许还有其他人(我不是确定在脚本中 Stefan Kruger的 的位置,或 Robert Dickau的 strong>视图)-为此会杀了我,但这是JavaScript自定义操作的模板(我尚未试用,但看起来还不错):

更新,2018年5月:不再推荐在VBScript上使用Javascript.

  1. C ++ dll
  2. 安装脚本(仅适用于InstallShield)
  3. VB脚本
  4. JavaScript
  5. C#DTF
  6. PowerShell

摘要:

  • 对我来说 PowerShell 在撰写本文时绝对是最糟糕的选择.这是两者托管代码(运行时不可靠),脚本自定义操作(调试不佳).
  • 我想像Chris一样编写 C#/DTF自定义操作,但是我不相信时机成熟-无法保证运行时环境.在现实世界中,您不会抛出支持C#dll的有效C ++ dll.这是一个巨大的可靠性降级.
  • C ++ dll Installscript 进行针对不同计算机的专业供应商设置的唯一选择(受管环境中不是标准台式机-公司,但世界上任何地方的计算机都处于不同状态,使用不同的语言以及各种硬件和软件配置.
  • 与其他自定义动作相比, C ++自定义动作dll 的设置,配置和输出要比其他自定义动作要难得多,但这并不是不可思议的.作为回报,您可以获得很多:全面的调试功能高级语言功能错误处理.最大的问题是:最小依赖项(请确保启用静态链接以消除所有可能的依赖项).对于调试,您可以简单地将Visual Studio调试器附加到自定义操作显示的消息框,然后可以逐步执行代码.这适用于用户和系统上下文自定义操作.完全控制.实际上,这使调试C ++自定义操作比脚本自定义操作更容易,并且当然更可靠.
  • JavaScript 我通常会避免.这不是一门完整的语言.我仍然认为它比托管代码更可靠-就运行时依赖性和可靠性(更少的运行时依赖性陷阱)而言.
  • 在托管环境中,
  • VB脚本对于"公司内部使用"是可接受的.我永远不会将其用于一般分发的供应商设置.但是可以在公司网络上分发软件包.对于开发人员来说,打包他们自己的应用程序以及对应用程序打包者都需要调整第三方设置以进行公司部署. VBScript操作的主要优点和缺点:
    • 如上所述,仅应在极少数情况下使用脚本,并且应将win32 C ++ dll或WiX的自定义操作dll用于人们倾向于重用的所有常见脚本任务.脚本仅在需要完成工作时使用.
    • 与所有脚本自定义操作一样,
    • VBScript自定义操作通常难以调试易受反病毒干扰缺少语言功能需要实施高级编码构造.您只是不具备C ++所具有的语言功能和灵活性(现在C ++自定义操作甚至可以被安全软件阻止-但这并不常见,但是随着安全性的提高,这种变化会发生吗?)
    • 脚本对每个人(目的和实现)都是透明的,并且可以由几名团队成员轻松地调试和维护,并在它们之间进行工作.所有人都可以看到正在发生的事情,每个人都可以快速处理别人的工作.
    • 嵌入在MSI 中的源是正确的源,您不需要像在托管代码(C#)中那样单独在存储库中维护源文件来对其进行编译.对于应用程序包装,源代码控制很少是我的经验(应该是).
    • 企业软件包针对的是标准操作环境(SOE).所有工作站都相似或相同,但具有相同的防病毒解决方案.显然,这意味着目标计算机所处的状态比正常情况要均匀得多.任何反病毒问题都将被检测到并可以管理.就个人而言,使用这种程序包部署的简单脚本,我还没有看到任何重大的防病毒干扰问题.
    • 在包装团队中,脚本调试方面往往有很多专业知识,但是对C ++的了解却很少(尽管很多人都了解一些C#和PowerShell).开发人员可能更喜欢C#,但可以轻松处理脚本.

我可以肯定的一件事是,托管代码自定义操作的可用性将导致人们在其设置中执行太多不应在设置中执行的操作(丰富的API ,相对容易编码).这是因为编码更容易,更快捷,并且所涉及的开发人员可能对应该如何进行正确的部署缺乏了解.这不可避免地导致各种自定义操作的过度使用,进而导致主要的部署问题,例如Error 1603

I'm looking into the solutions on that page but all of that should be in order. We're running the installer in the same way with the same permissions on the Win 10 and Win 7 VM's.

I doubt this will be enough information to get any concrete responses, so more than anything I'm looking for constructive advice how where to look and how to figure this out. I have more details I could post, but it's such a large volume of information and I don't know how to pick out what is genuinely relevant.

解决方案

Adding this as an answer - it is too long as a comment, and I think it is the correct answer as well. If you read this answer, please also see my comment above for a very good MSI log file debugging tip from Rob Mensching (creator of WiX) - and how to ensure all entries make it into the log file by enabling "flush to log" for crashing custom actions.


The Answer

Dependency on a missing runtime like Powershell would certainly trigger the rollback. MSI hosts its own runtime for certain script custom actions (active scripting). For example VBScript and JavaScript. For reliable deployment, it is recommended that all custom actions used be either self-contained minimum-dependency C++ dlls or executables (win32) or (less desirable) VBScript or JavaScript (or even Installscript if you use Installshield - see details below).

Disputed opinion of mine: The worst custom actions to use for reliability and robustness are .NET binaries requiring a specific version of the .NET framework. This also applies to PowerShell - which is not only managed code, but also a script. I am very tempted to say that these technologies shouldn't be used for deployment, but if you need to use PowerShell you must at a minimum add a "verify PowerShell installed" custom action at the start of your setup, and exit gracefully with a proper error message displayed (and/or logged) if PowerShell is not available.

That is the end of the real answer :-). Below are some "verbose musing" in case you are making a package for general distribution (and not just a package for your own company's internal deployment). If I were you I would read it even if you only deploy internally, PowerShell custom actions could be a brewing deployment problem of caliber.

Both managed code and scripts are problematic. PowerShell is effectively both at the same time. Here is Rob Mensching's blog on why script custom actions are bad. Essentially: scripts are fragile, they lack language features, they are hard to debug and anti-virus products often block them. Read the blog. And here is Aaron Stebner's blog on why managed code is bad. Essentially you are not guaranteed a proper runtime environment when you depend on the presence of the .NET framework.


Verbose Musings

I am not sure what is installed as standard on Win7 and Win10. If your are deploying as an "internal package" to your company, I think it should be OK to just add a reliable check for the presence of PowerShell, and then to abort with a meaningful error message if PowerShell is not found. Opinion Warning: But overall .NET binaries and PowerShell scripts are the worst custom actions for reliability. I would never use them for setups targeting diverse computers.

If you are making an MSI for general distribution to any computer anywhere, I would take the time to convert the PowerShell script to something else. Preferably a C++ dll - which I find most reliable. There are no dependencies to speak of or layers to depend on. Even InstallScript is acceptable if you would have been using Installshield (it can run without a pre-installed runtime at this point - which has significantly improved its reliability and usefulness - it is an obtuse language though with rather archaic syntax. In fairness, not to be underestimated - it does the job, and is simpler than C++).

JavaScript and VBScript custom actions are possible to use even for MSIs that are for general distribution to any computer, but still not recommended. I tend to use them only for "internal company deployment" packages. These can be standardized and crucially scripts are transparent to other system administrators and packagers. They can see and inspect what is being done as part of the installation. This is generally desirable and one of the key benefits of MSI for corporate deployment, but sometimes you need a compiled binary to hide implementation details (for example when you validate a license key). Then scripts of any kind can't be used - obviously. By being transparent and also embedded in the MSI (so the full, running source is always available), it helps different application packagers to be able to pick up someone else's work when need be. And in a deployment team there is always someone available to debug scripts - but few may know proper C++. In corporations where developers of internal applications make their own MSI files without much deployment knowledge, scripting can go completely astray and cause very difficult deployment problems. Very often what is needed is small changes to the application itself to allow more reliable deployment. An application should do its own startup configuration for example - none of this should be done in setup scripts, but many developers do this.

Using script custom actions is controversial. If you ask 2 development experts you will get 4 opinions. In my view "white box" custom actions (scripts) are good for corporate use if they do something specific that isn't common so people can see what is going on. For stuff that is needed all the time, a corporation should make a compiled C++ dll driven by custom tables in the MSI file with full QA and rollback support - something that is generally always missing for all script custom actions (it isn't trivial to implement). A "data driven" (custom tables) C++ custom action has minimal dependencies as its biggest strength, and it is also transparent (what will happen is transparent, but the actual implementation is compiled and hidden - which can also improve security). The WiX toolkit provides such a custom action dll with rollback support written in C++. It should solve most custom tasks required for corporate deployment. All of this is way beyond your question though - just a digression :-).


If I were to guess I would say that Windows Installer might be updated to be able to host its own runtime for Powershell - but this is just speculation. I am not sure of the technical details - it would seem the whole .NET runtime would be needed? If you ask me, I would still prefer a JavaScript to a PowerShell script, but I realize you are probably committed to PowerShell as a company standard? Also, always prefer JavaScript over VB Script since it has something that looks like exception handling (which VB Script lacks entirely). UPDATE: real-world testing indicates that VBScript is actually better to use with MSI than Javascript. For example: I have seen obscure problems when accessing the MSI API with Javascript. MSI itself was probably tested more with VBScript than with Javascript when it was created. Let's be honest: both "languages" have severe limitations and both are hard to debug.

Rob Mensching, Chris Painter, Phil Wilson, Bob Arnson and probably others too (I am not sure of Stefan Kruger's position on scripts, or Robert Dickau's view) - will kill me for this, but here is a template for a JavaScript custom action (untested by me, but looks OK): How to debug an MSI Custom Action that is implemented in Javascript? . If I can just blurt it out: anything is better than PowerShell at the present time - even JavaScript.

Rest assured, I have wasted a lot of time debugging extremely poor VB Script custom actions. Probably the most incompetent and deprived language ever used for deployment. On Error Resume Next for error handling? It can't get much worse. I generally only use scripts for read-only operations and set property actions.

Maybe we will see VB Script deprecated and PowerShell added as a viable MSI scripting option in due time? I wouldn't judge this as safe until all operating systems in use would have at least a baseline version of the .NET framework installed - and even then I believe policies could lock specific versions of .NET from being used. Do you want a package that suddenly can't uninstall because the target version of the .NET framework is no longer operational? Fixing such an issue could be an incredible amount of work - especially for a corporation with a large package estate (thousands of packages, thousands of machines).


Recommended Custom Action Implementation

I wrote up a summary of "recommendations" for custom action implementation. It became pages long without saying much - I deleted it. Instead, here is a list of my custom action implementation preference (in order of decreasing robustness and reliability): 

UPDATE May,2018: no longer recommending Javascript over VBScript.

  1. C++ dll
  2. Installscript (InstallShield only)
  3. VB Script
  4. JavaScript
  5. C# DTF
  6. PowerShell

Summary:

  • For me PowerShell is at the time of writing absolutely the worst choice. It is both managed code (unreliable runtime) and a script custom action (poor debugging).
  • I would like to write C# / DTF custom actions like Chris does for simplicity, but I don't believe the time is ripe - the runtime environment cannot be guaranteed. In the real world you don't throw out a working C++ dll in favor of a C# dll. It is a huge reliability downgrade.
  • C++ dll and Installscript are the only choices for making a professional, vendor setup targeting diverse computers (not standardized desktops in managed environments - corporations, but computers anywhere in the world in all their heterogeneous states, in different languages and diverse hardware and software configurations).
  • A C++ custom action dll is significantly harder to set up and configure than other custom actions with its exports, build settings and outputs, but it is no magical impossibility. In return you get a lot: full debugging capability, advanced language features and error handling. And the big one: minimum dependencies (make sure you enable static linking to eliminate all possible dependencies). For debugging you can simply attach the Visual Studio debugger to a message box displayed by your custom action, and then you can step through code. This works for both user and system context custom actions. Full control. This actually makes debugging a C++ custom action easier than a script custom action, and certainly more reliable.
  • JavaScript I would generally avoid. It just isn't a complete language. I still think it is more reliable than managed code though - in terms of runtime dependencies and reliability (fewer runtime dependency pitfalls).
  • VB Script is acceptable for "internal corporate use" in a managed environment. I would never use it for a vendor setup for general distribution. But to distribute packages on a corporate network it can be used. Both for developers packaging their own applications, and for application packagers tweaking third party setups for corporate deployment. The primary advantages and disadvantages of VBScript actions:
    • As stated above, scripts should only be used in rare cases, and a win32 C++ dll or WiX's custom action dll should be used for all common scripting tasks that people tend to re-use. Scripts are only to be used when needed to get the job done.
    • VBScript custom actions are, like all script custom actions, in general hard to debug, vulnerable to anti-virus interference and lacking in language features needed to implement advanced coding constructs. You just don't have the language features and flexibility available with C++ (now even C++ custom actions can be blocked by security software - but it is not as common, but could that change as security is tightened?)
    • Scripts are transparent for everyone (both purpose and implementation) and can be debugged and maintained easily by several team members with work handed off between them. All can see what is going on and everyone can pick up someone else's work quickly.
    • The source embedded in the MSI is the right source, you don't need to maintain source files separately in a repository to compile it like you need for managed code (C#). For application packaging source control is rarely set up is my experience (it should be though).
    • Corporate packages target a standard operating environment (SOE). All the workstations are similar or the same, with the same anti-virus solution. This obviously means that the target computers are in a much more uniform state than what is normal. Any anti-virus issues will be detected and can be managed. Personally I haven't seen any major anti-virus interference problems with simple scripts for such package deployment.
    • There tends to be a lot of expertise in script debugging in packaging teams, but very little C++ knowledge (many know some C# and PowerShell though). Developers would likely prefer C#, but can easily handle scripts.

One thing that I am certain of, is that the availability of managed code custom actions will cause people to do way too many things in their setups that should never be done in a setup (rich API, relatively easy coding). This is all because coding is easier and faster, and the developer in question may lack an understanding of how proper deployment should be done. This inevitably leads to overuse of custom actions of all kinds, and in turn major deployment problems as the complexity of custom actions trigger unexpected errors.

这篇关于Windows Installer在Win 10上失败,但在使用WIX的Win 7上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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