简体   繁体   English

(Wix 安装程序)如何包含自定义操作依赖项

[英](Wix installer) how to include custom action dependency

I got 3 projects in Install solution:我在安装解决方案中有 3 个项目:

  1. Custom Action dll written in c#用c#编写的自定义操作dll
  2. Custom Action dll written in c++用 C++ 编写的自定义操作 dll
  3. Util dll written in c++ also (c# and c++ uses it, as interoop) Util dll 也用 c++ 编写(c# 和 c++ 使用它,作为互操作)

The question is how to add Util.dll into wix installer,问题是如何将Util.dll添加到wix安装程序中,

When I copy/paste this dll into C:\\ProgramFiles\\SystemWOW64\\ (the msiexec.exe directory) all works fine, but its a bad workaround which I would to avoid.当我将此 dll 复制/粘贴到 C:\\ProgramFiles\\SystemWOW64\\(msiexec.exe 目录)时,一切正常,但这是我要避免的一种糟糕的解决方法。

What I've tried: 1) Add as reference to the MSI project and include as:我尝试过的: 1)添加作为对 MSI 项目的引用并包括为:

   <?xml version="1.0" encoding="utf-8"?>
   <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
      <Fragment>
         <Binary Id="CPlusPlusAction" SourceFile="$(var.CPlusPlusAction.TargetDir)$(var.CPlusPlusAction.TargetName).CA.dll"/>
         <Binary Id="CSharpAction" SourceFile="$(var.CSharpAction.TargetPath)"/>
         <Binary Id="Utils" SourceFile="$(var.SolutionDir)/$(var.Utils.Configuration)/Utils.dll"/>
         <CustomAction Id="FunctionOne" Impersonate="no" Return="ignore" Execute="commit" BinaryKey="CPlusPlusAction" DllEntry="FunctionOne" />
         <CustomAction Id="FunctionTwo" Impersonate="no" Return="ignore" Execute="commit" BinaryKey="CSharpAction" DllEntry="FunctionTwo"/>
      </Fragment>
  </Wix>

2) Add as reference to both projects with CopyLocal = true 2) 使用 CopyLocal = true 添加对两个项目的引用

I've googled a lot but still can't find the solution ( Wix Doc , StackOverflow, msdn etc)我用谷歌搜索了很多,但仍然找不到解决方案( Wix Doc 、StackOverflow、msdn 等)

Thanks in advance提前致谢

For C# managed custom actions I don't think you can add the native dll as a reference.对于 C# 托管的自定义操作,我认为您不能添加本机 dll 作为参考。 So instead add it as content with action copy and I'm pretty sure DTF will package it up and make it available in the temp directory (current directory of the process) at custom action execution time.因此,改为将其添加为操作副本的内容,我很确定 DTF 会将其打包并在自定义操作执行时使其在临时目录(进程的当前目录)中可用。

For C++, I use the ISSetup.dll / ISSetupFile pattern from InstallShield or statically link the library if you can.对于 C++,我使用 InstallShield 中的 ISSetup.dll / ISSetupFile 模式,或者如果可以的话静态链接库。

Thanks for answer guys, but finally I figured it out.谢谢大家的回答,不过终于搞明白了。

First of all you need to add this Util.dll to Msi binary table:首先你需要把这个 Util.dll 添加到 Msi 二进制表中:

<Binary Id="Utils" SourceFile="$(var.SolutionDir)/$(var.Utils.Configuration)/Utils.dll"/>

If you are not sure use Orca for seeing it inside .msi file如果您不确定使用 Orca 在 .msi 文件中查看它

Second as Christopher said for c# its enaught to RightClick -> Add Existing project -> Utill.dll, then DFS extract it during installation into C:/windows/installation/"CustomActionId" and everything works, but...其次,正如克里斯托弗所说的 c#,它对右键单击 -> 添加现有项目 -> Utill.dll 来说毫无意义,然后 DFS 在安装过程中将其解压缩到 C:/windows/installation/"CustomActionId" 中,一切正常,但是......

problem is with c++ side, the Wix isn't for this language, so you need to care of everything during installation, for example write code which will read the BinaryTable for installer, read data and clean all msdn it's a lot of code问题在于 C++ 方面,Wix 不适用于这种语言,因此您需要在安装过程中处理所有事情,例如编写代码来读取安装程序的 BinaryTable,读取数据并清理所有msdn,这是很多代码

so I prefer to write CLR wrapper for util, Build Util as lib, so on c++ side its build inside CA.dll, and add as lib to wrapper, so now you can use wrapper.dll in c#所以我更喜欢为util编写CLR包装器,将Util构建为lib,所以在c++端它在CA.dll中构建,并将lib添加到包装器中,所以现在你可以在c#中使用wrapper.dll

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM