Jak dodać akcję niestandardową do projektu konfiguracji Wix
Mam 2 projekty w mojej solucji:
1). Niestandardowa klasa akcji (CustomAction)
2). Projekt instalacji Wix (TestSetup)
W projekcie CustomAction znajduje się 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:
<?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>
Projekt instalacji budzi się bez problemów, ale gdy próbuję go uruchomić, pojawia się komunikat o błędzie: „Wystąpił problem z tym pakietem Instalatora Windows. Nie można uruchomić biblioteki DLL wymaganej do wykonania tej instalacji. Skontaktuj się z personelem pomocy technicznej lub sprzedawca pakietów ”
Myślę, że to z powodu niepoprawnej wartości binarnego pliku źródłowego. Czy chcesz pokazać, jak to naprawić?