简体   繁体   English

如何向wix安装项目添加自定义操作

[英]How to add custom action to wix setup project

I have 2 projects in my soliution: 我的解决方案中有2个项目:

1). 1)。 Custom action class (CustomAction) 自定义操作类(CustomAction)

2). 2)。 Wix setup project (TestSetup) Wix安装项目(TestSetup)

There is CustomAction.cs in CustomAction project: CustomAction项目中有CustomAction.cs:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;

namespace CustomAction
{
    public class CustomActions
    {
        [CustomAction]
        public static ActionResult CustomAction1(Session session)
        {
            File.Create(@"c:\installed.txt");

            return ActionResult.Success;
        }
    }
}

Product.wxs: Product.wxs:

<?xml version="1.0" encoding="UTF-8"?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" Name="TestSetup" Language="1033" Version="1.0.0.0" Manufacturer="SB2"
           UpgradeCode="39d922d3-a3f5-4207-b905-124615dda25d">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate EmbedCab="yes"/>

    <Feature Id="ProductFeature" Title="TestSetup" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>
    <InstallExecuteSequence>
      <Custom Action="CustomAction" Before="InstallFinalize" />
    </InstallExecuteSequence>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="TestSetup" />
      </Directory>
    </Directory>
  </Fragment>
  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component Id="result.rtf">
        <File Id="result.rtf" Source="result.rtf" KeyPath="yes" Checksum="yes" />
      </Component>
    </ComponentGroup>
  </Fragment>

<Fragment>
    <CustomAction Id='CustomAction' BinaryKey='CustomAction.CA' DllEntry='CustomAction' />
    <Binary Id='CustomAction.CA' SourceFile='..\CustomAction\bin\Debug\CustomAction.CA.dll' />
</Fragment>  
</Wix>

Setup project buils without problems, but when I'm trying to run it I get a error message: "There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor" 安装项目建立没有问题,但当我尝试运行它时,我收到一条错误消息:“此Windows Installer程序包有问题。无法运行此安装所需的DLL。请联系您的支持人员或包装供应商“

I think it's because of incorrect binary source file value. 我认为这是因为二进制源文件值不正确。 Would you to show how to fix it? 你会说明如何解决它吗?

The problem is that your CustomAction method name "CustomAction1" does not match with the "DLLEntry" value which you have mentioned (DllEntry='CustomAction'). 问题是您的CustomAction方法名称“CustomAction1”与您提到的“DLLEntry”值不匹配(DllEntry ='CustomAction')。 You are missing "1" :) 你错过了“1”:)

<CustomAction Id='CustomAction' BinaryKey='CustomAction.CA' DllEntry='CustomAction' />

You should write like this:- 你应该这样写: -

<CustomAction Id='CustomAction' BinaryKey='CustomAction.CA' DllEntry='CustomAction1' />

where CustomAction1 is your CustomAction Name.. 其中CustomAction1是您的CustomAction名称..

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

相关问题 Wix无法向项目添加自定义操作 - Wix can't add Custom Action to project 将自定义操作添加到VS 2008安装项目 - Add Custom action to VS 2008 Setup project Wix:将项目添加到安装程序包 - Wix: Add project to setup package 如何在C#中创建自定义操作并将其绑定到Wix安装项目上 - How to create custom actions in c# and bind it on a wix setup project 如何安装从维克斯自定义引导程序/卸载单MSI软件包包含多个类似的MSI安装项目的添加/删除功能? - How to install / uninstall single msi from wix custom bootstrapper bundle containing multiple MSIs like add/remove feature of Setup project? 在Visual Studio 2017安装项目中为卸载添加自定义操作 - Add a custom action on uninstall in Visual Studio 2017 setup project 在安装程序项目中的安装之前添加安装MSI的自定义操作 - Add custom action of installing msi before the setup in installer project 如何将WIX安装项目与WIX Bootstrapper项目相结合 - How to Combine WIX Setup Project with WIX Bootstrapper Project 在具有多个依赖项的 Wix 中添加自定义操作 - Add custom action in Wix with multiple dependencies WiX安装程序在静音和“正常”模式下启动相同的自定义操作 - WiX Setup launching same custom action in silent and “normal” mode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM