こんにちは私はWixを使用してインストーラを作成しています。このインストーラは、インストーラがユーザのシステムにコピーするファイルのパスにレジストリ値を書き込む必要があります。問題は、レジストリエントリがこの形式私は私は本当に後者の表記を変換するのに苦労していますWixで文字列を操作してプロパティを設定するカスタムアクション
C:\Program Files\....
を指すINSTALLFOLDERディレクトリIDを持ってウィックスコードプロジェクトで
file:///C:/Program Files/....
で書かれるべきであるということです前者に私はそれを使用できるようにプロパティを設定することを望むカスタムアクションを作成しました。コード
カスタムアクションされ、次の(今のところ別のDLLは、それをインライン化することができますか?)
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
session.Log("Begin CustomAction1");
string origValue = session["INSTALLFOLDER"];
MessageBox.Show(origValue);
string retVal = origValue.Replace("\\", "//");
MessageBox.Show(retVal);
session["Custom_Prop"] = retVal;
return ActionResult.Success;
}
}
そしてProduct.wxsを
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupProject1" Language="1033" Version="1.2.0.0" Manufacturer="nik" UpgradeCode="4a74ff86-49a9-4011-9794-e1c18077172f">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupProject1" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<InstallExecuteSequence>
<Custom Action='FooAction' Before='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
</Product>
<Fragment>
<CustomAction Id='FooAction' BinaryKey='FooBinary' DllEntry='CustomAction1' Execute='immediate'
Return='check'/>
<Binary Id='FooBinary' SourceFile='MyCustomAction.CA.dll'/>
</Fragment>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<Property Id="Custom_Prop" Value="[ProgramFilesFolder]"></Property>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
<Component Id="cmp_Add_Mainfest_To_Registry" Guid="955A3A76-F010-4FCB-BCAF-B297AFD1C05B">
<RegistryKey Root="HKCU" Key="SOFTWARE\company">
<RegistryValue Name="LoadBehavior" Value="3" Type="integer" Action="write" />
<RegistryValue Name="Manifest" Value="[Custom_Prop]" Type="string" Action="write" KeyPath="yes"/>
</RegistryKey>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
しかし、私は値が書かれた、このセットアップを実行するとC:\またはC:/
誰かに助けてもらえるリテラル文字列[ProgramFolder]です。