我需要一个 MSI 自定义操作来从 MSI 源目录复制文件

发布于 2024-07-10 03:08:11 字数 370 浏览 6 评论 0原文

我正在使用 VS 2008 为 ac# windows 项目创建一个安装程序。我正在尝试编写一个自定义操作,该操作从存储在文件服务器上的 MSI 文件的源目录复制设置文件(例如 \server\fileshare\myappinstaller \mysetting.xml)复制到安装我的应用程序的计算机上的目标目录(例如 C:\Program Files\My App)。

设置文件无法添加到安装程序中,因为它将包含安装应用程序的客户所独有的设置。

有人有这样的自定义操作的代码(最好是 C# 或 VB.NET)吗? 或者,是否有人知道如何在自定义操作中获取 MSI 源位置(例如 \server\fileshare\myappinstaller)。

非常感谢

I'm creating a installer for a c# windows project using VS 2008. I'm trying to write a custom action that copies a settings file from the source directory of the MSI file stored on a file server (e.g. \server\fileshare\myappinstaller\mysetting.xml) to the target directory on the computer on which my application is been installed (e.g. C:\Program Files\My App).

The settings file can't be added in to the installer as it will contain settings with will be unique to the customer installing the app.

Does anyone have code (preferably C# or VB.NET) for such a custom action? Alternately does anyone know how to get the MSI source location (e.g. \server\fileshare\myappinstaller) within a custom action.

Many thanks

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

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

发布评论

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

评论(4

じее 2024-07-17 03:08:11

我已经通过添加解决了这个问题

/InstallerPath="[原始数据库]"

到自定义操作的 CustomActionData(在安装项目的选项卡自定义操作中),并在自定义操作中使用此代码读取值:

    Public Overrides Sub Commit(ByVal savedState As System.Collections.IDictionary)
        MyBase.Commit(savedState)

        Dim directoryOfMSI As String = IO.Path.GetDirectoryName(Context.Parameters("InstallerPath"))

        'Do your work here
        '...

    End Sub

Ciao!
斯特凡

I have solved this by adding

/InstallerPath="[OriginalDatabase]"

to the CustomActionData of the Custom Action (in the Tab Custom Actions of the Setup Project) and reading the value with this code in the Custom Action:

    Public Overrides Sub Commit(ByVal savedState As System.Collections.IDictionary)
        MyBase.Commit(savedState)

        Dim directoryOfMSI As String = IO.Path.GetDirectoryName(Context.Parameters("InstallerPath"))

        'Do your work here
        '...

    End Sub

Ciao!
Stefan

入怼 2024-07-17 03:08:11

我建议您将 XML 文件添加到安装程序中作为要安装的组件之一。 这将是最简单的方法,不需要自定义操作。

WiX 可能是您的一个选择。 它允许您在安装过程中使用 XmlConfig 自定义 XML 配置文件。

I would recommend you to add the XML file to the installer as one of the components to be installed. That would be the easiest way and would not require a custom action.

WiX might be an option for you. It allows you to customize XML configuration files during installation using XmlConfig.

忆沫 2024-07-17 03:08:11

我做了类似的事情,但在 MSI 文件中发送默认配置,然后使用 MST 添加自定义配置文件。 它更加可靠,因为一切都是 Windows 安装程序“本机”的,我只需要向每个客户发送一个小的自定义 MST。

有关如何执行此操作的更多信息,请访问 替换 MSI 内小文件的最简单解决方案?

I do a similar thing, but ship a default configuration inside the MSI file and then use a MST to add the custom configuration file. It's much more reliable as everything is "native" to windows installer and I just need to send out a small custom MST to each customer.

More information on how I'm doing this can be found over at Simplest solution to replace a tiny file inside an MSI?

打小就很酷 2024-07-17 03:08:11

通常,WindowsInstaller 中的自定义操作使用 msi 表中的某些内容将某些内容放入 msi 的任何表中。

此外,WindowsInstaller 团队拒绝安装程序的任何托管扩展,其原因在网络上随处可见。

但是,我不久前确实为 WindowsInstallers 找到了创建托管自定义操作的扩展,可以与 WiX 一起使用,它仍然可以工作,但是在该工作之上有一个更新的解决方案,一个真正的扩展WiX 允许托管自定义操作。

Normally custom actions in WindowsInstaller use something from the tables of the msi to put something into any table of the msi.

Additionally the WindowsInstaller-Team declines any managed extensions for the installers, reasons for that are found everywhere on the net.

But, I did some time ago figure out an extension to create managed custom actions for WindowsInstallers, usable with WiX, that works still, but there is a newer solution on top of that work, a real extension for WiX to allow managed custom actions.

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