无需其他先决条件的自定义操作 [英] Custom actions without additional prerequisites

查看:61
本文介绍了无需其他先决条件的自定义操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去,我用VBScript编写了所有自定义操作,因为我的理解是,这种(和JScript)是唯一一种不需要在目标系统上具有其他先决条件的自定义操作.

In the past I've written all my custom actions in VBScript, because my understanding is that this (and JScript) is the only type of custom action which does not require additional prerequisites on the target system.

但是,编写VBScript很麻烦,现在我还遇到了一个问题,该问题显然无法在VBScript中解决(请参见非英语语言环境(编码问题?)).

However, writing VBScript is a pain, and now I also encountered a problem which apparently cannot be solved in VBScript (see Currupted file in non-english locale (encoding problem?)).

因此,我正在考虑使用C#自定义操作.但是我不想为自定义操作引入其他先决条件(请注意,我要安装的应用程序不使用.NET Framework).

So I'm considering using a C# custom action instead. But I don't want to introduce additional prerequisites just for the custom action (note that the application I'm installing does not use the .NET Framework).

此网站上说

This list shows which Windows version includes which .NET Framework version. Assuming that newer .NET Framework versions are backwards compatible, it looks like a .NET Framework 2.0 custom action should run on virtually any Windows version (except for XP, which I don't care about) out of the box. But then on this site it says

此外,如果您的应用程序针对版本2.0、3.0或3.5,则可能要求您的用户在Windows 8,Windows 8.1或Windows 10计算机上启用.NET Framework 3.5,然后才能运行您的应用程序./p>

In addition, if your app targets version 2.0, 3.0, or 3.5, your users may be required to enable the .NET Framework 3.5 on a Windows 8, Windows 8.1, or Windows 10 computer before they can run your app.

所以看起来新的.NET Framework版本向后兼容的假设是不正确的...

So it looks like the assumption that newer .NET Framework versions are backwards compatible is not correct...

WiX自定义操作项目使用以下设置创建了一个CustomAction.config文件:

The WiX custom action project created a CustomAction.config file with the following settings:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" />
        <supportedRuntime version="v2.0.50727"/>
    </startup>
</configuration>

因此,这里有几个问题:

So here are a few questions:

  1. 我可以假定具有上述配置的.NET Framework 2.0自定义操作可以在任何Windows(XP除外)上运行吗?还是尽管配置文件将4.0声明为受支持的运行时,但仍需要在Windows的较新版本上启用.NET Framework 3.5?
  2. 一般来说,在不引入任何其他先决条件的情况下创建自定义动作(不是VBScript或JScript)的最佳方法是什么?(我当时正在考虑用于WiX v3的C ++自定义操作项目",但是看起来这就像创建了一个托管C ++项目,因此围绕.NET Framework出现了同样的问题.)
  1. Can I assume that a .NET Framework 2.0 custom action with the above config runs on any Windows (except for XP)? Or does .NET Framework 3.5 need to be enabled on newer versions of Windows despite the fact that the config file states 4.0 as a supported runtime?
  2. What's generally speaking the best way to create a custom action (not VBScript or JScript) without introducing any additional prerequisites? (I was considering a "C++ Custom Action Project for WiX v3", but it looks like this creates a managed C++ project, so the same questions around .NET Framework arise).

更新:

我在新的Windows Server 2008 R2和新的Windows 10 VM中测试了此.NET Framework 2.0自定义操作.运行自定义操作无需手动安装.NET Framework.因此,基于这个小的测试,看来这种自定义操作的兼容性非常好.

I tested this .NET Framework 2.0 custom action in a fresh Windows Server 2008 R2 and in a fresh Windows 10 VM. The custom action ran without needing to install the .NET Framework manually. So based on this little test it looks like compatibility of such a custom action is quite good.

推荐答案

.NET自定义操作存在一些问题.我有这个旧答案-我已经有一段时间没有对此进行评论了.我记得我曾经以为那天我一定失去了头脑"而读过它.答案结尾处的列表中提到了一些托管代码问题(迅速: 1) 依赖性过多, 2) CLR版本加载行为问题(最新?), 3) GAC依赖项, 4) 缺少最小的依赖关系和卸载问题, 5) ..NET运行时损坏或不可用,等等.).我不是这个主题的专家.

There are some issues with .NET custom actions. I have this old answer - that I haven't reviewed in a while. I remember I read it once thinking "I must have lost my mind that day". It is the list towards the end of the answer that mentions a few managed code problems (quickly: 1) too many dependencies, 2) CLR version load behavior issues (up to date?), 3) GAC dependencies, 4) lack of minimal dependencies and uninstall issues, 5) Broken or unavailable .NET runtime, etc...). I am not an expert on this topic.

随着时间的流逝,使用.NET似乎会变得越来越好,因为运行时现在已成为操作系统的一部分.您可以锁定安装程序,使其不会通过启动条件安装在下游操作系统上.而且没有很多 CLR版本-基本上只有2个和4个?

It seems to get better over time to use .NET because the runtime is now part of the OS. You can lock a setup so it won't install on downstream OS by means of Launch Conditions. And there aren't that many CLR versions - just 2 and 4 basically?

以下是分别使用C ++和C#/.NET进行自定义操作的两个答案:

Here are two answers on using C++ and C# / .NET respectively for custom actions:

Remember the propaganda against custom actions. They are error prone. Very.

链接 :

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