好了,我已经决定,我可以用WiX做我想做的事情的唯一方法(感谢一个我没有写的旧安装程序,现在我必须升级)是通过一些自定义操作。
基本上,我需要在RemoveExistingProducts之前备份一个文件,并在RemoveExistingProducts之后再次恢复该文件。我认为这就是所谓的“类型2自定义操作”。
然而,我想我理解的顺序是,我不理解的是首先我如何将数据传递给我的C#操作(来自WiX的文件所在的目录),以及如何引用我的C# (DTF?)使用Binary和CustomAction标记执行操作。
另外,所有这些都需要放在一个标签中吗?所有的例子都说明了这一点。
以下是我到目前为止在.WXS文件中拥有的内容...
<Binary Id="backupSettingsAction.dll"
SourceFile="backupSettingsAction.CA.dll"/>
<CustomAction
Id="BackupSettingsAction"
BinaryKey="backupSettingsAction.dll"
DllEntry="CustomAction"
Execute="immediate" />
<InstallExecuteSequence>
<Custom Action="backupSettingsAction.dll" Before="InstallInitialize"/>
<RemoveExistingProducts After="InstallFinalize" />
<Custom Action="restoreSettingsAction.dll" After="RemoveExistingFiles"/>
</InstallExecuteSequence>我需要备份的文件是上一次安装的设置文件(需要保持不变),它位于以下目录:
<Directory Id="CommonAppDataFolder" Name="CommonAppData">
<Directory Id="CommonAppDataPathways" Name="Pathways" />
</Directory>它甚至有一个组件标签,尽管我需要备份已经存在的文件:
<Component Id="Settings" Guid="A3513208-4F12-4496-B609-197812B4A953" NeverOverwrite="yes" >
<File Id="settingsXml" ShortName="SETTINGS.XML" Name="Settings.xml" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\Settings\settings.xml" Vital="yes" />
</Component>这是引用Visual Studio (2005)为我创建的C#文件:
namespace backupSettingsAction
{
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
session.Log("backing up settings file");
//do I hardcode the directory and name of the file in here, or can I pass them in?
return ActionResult.Success;
}
}
}任何帮助都会得到极大的支持。谢谢!
发布于 2010-06-02 07:57:37
我们可以回到为什么你认为你需要一个自定义操作的时刻吗?
根据您试图解决的问题,您应该能够做以下两件事之一
1)将XML文件放入它自己的组件中,标记为keyfile并设置为permanent。
2)创建一个虚拟DLL,并将其版本设置为1.0.0.0。以后永远不要递增此DLL的版本号。将DLL和XML文件放入组件中,并将DLL设置为keyfile,将组件设置为permanent。
您现在应该能够进行重大升级,并持久化XML文件的内容,而不管它是否被修改为包含用户数据。
https://stackoverflow.com/questions/2953366
复制相似问题