本文介绍了如何将自定义操作添加到Wix安装项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个项目需要解决:

I have 2 projects in my soliution:

1)。自定义操作类(CustomAction)

1). Custom action class (CustomAction)

2)。 Wix设置项目(TestSetup)

2). Wix setup project (TestSetup)

CustomAction项目中有CustomAction.cs:

There is CustomAction.cs in CustomAction project:

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>

安装项目可以正常运行,但是当我尝试运行它时,出现一条错误消息:
此Windows Installer软件包存在问题。无法运行完成此安装所需的DLL。请与您的支持人员或软件包供应商联系。

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"

我认为这是因为二进制源文件值不正确。
您能否说明如何解决?

I think it's because of incorrect binary source file value.Would you to show how to fix it?

推荐答案

问题是您的CustomAction方法名称 CustomAction1与您提到的 DLLEntry值不匹配( DllEntry ='CustomAction')。您缺少 1:)

The problem is that your CustomAction method name "CustomAction1" does not match with the "DLLEntry" value which you have mentioned (DllEntry='CustomAction'). You are missing "1" :)

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

这篇关于如何将自定义操作添加到Wix安装项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-08 05:45