WiX 卸载时删除文件但不更新 [英] WiX Remove files on uninstall but not update

查看:31
本文介绍了WiX 卸载时删除文件但不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它可以在安装时给出正确的标志时进行记录(/logLevel=debug 在安装时会在服务启动时传递给应用程序).我们的更新过程是自动卸载,然后使用新的 MSI 包进行安装.我知道 WiX 内置了补丁功能,但这是我们的流程.

I have an app that can log when given the correct flags at install time (/logLevel=debug on install gets passed to the app when the service starts). Our update process is a automated uninstall then install with a new MSI package. I know there is built in patch functionality with WiX, but this is our process.

logLevel 参数类似,我想在卸载过程中在命令行上传递一些内容以达到 UPDATE="true" 的效果.当这个参数传递给卸载程序时,它应该删除日志文件.目前我们每次都删除文件,但希望在更新期间保留日志文件.这就是我现在想要扩展的内容:

Similarly with the logLevel parameter, I'd like to pass something to the effect of UPDATE="true" on the command line during uninstall. When this parameter is passed to the uninstaller it should not delete the log files. Currently we delete the files every time, but would like to retain the log files during an update. This is what I am trying to extend as of right now:

<?if $(var.BUILD_CONFIG) = "Debug" ?> 
<?else?>
  <CustomAction Id="Cleanup_logfile" Directory="TempTest"
   ExeCommand="cmd /C &quot;del %systemroot%\temp\hexis_hawkeye_g.log.*&quot;"
   Execute="deferred" Return="ignore" HideTarget="no" Impersonate="no" />

  <InstallExecuteSequence>
    <Custom Action="Cleanup_logfile" Before="RemoveFiles" >
      REMOVE="ALL"
    </Custom>
  </InstallExecuteSequence> 
<?endif?> 

而且我一直在使用类似于以下内容的代码,但它似乎不起作用:

And I've been playing with code similar to something like the following but it doesn't seem to work:

<?if $(var.BUILD_CONFIG) = "Debug" ?> 
<?else?>
  <?if '[UPDATE]' = "true" ?>
  <?else?>
    <CustomAction Id="Cleanup_logfile" Directory="TempTest"
     ExeCommand="cmd /C &quot;del %systemroot%\temp\hexis_hawkeye_g.log.*&quot;"
     Execute="deferred" Return="ignore" HideTarget="no" Impersonate="no" />

    <InstallExecuteSequence>
      <Custom Action="Cleanup_logfile" Before="RemoveFiles" >
        REMOVE="ALL"
      </Custom>
    </InstallExecuteSequence> 
  <?endif?>
<?endif?>

我不确定我是否没有正确初始化 UPDATE 变量,或者这是否真的是一些无法以这种方式实现的预处理.我认为它不会工作,因为这些构造在预处理器文档页面上进行了描述,但是,/logLevel 和各种其他参数在运行时安装时似乎可以正常工作.我完全是 WiX 文盲,一直在尝试阅读他们的文档但无济于事,感谢任何有用的链接.

I'm not sure if I'm not initializing the UPDATE variable correctly, or if this really is some pre-processing that cannot be implemented in this fashion. I would think it would not work because these constructs are described on the preprocessor doc page, however, the /logLevel and various other parameters seem to work fine at run-time installation. I'm totally WiX illiterate and have been trying to read their documentation to no avail, any helpful links appreciated.

推荐答案

我所看到的问题:在卸载应用程序的主要升级期间(以及稍后安装新版本)REMOVE=ALL 在卸载应用程序时也是如此,因此文件将被删除.
您需要另外检查 UPGRADINGPRODUCTCODE 也设置或不设置,这只会在更新期间为真.

The problem as I see it: during a major upgrade when the application is uninstalled (and later on installing the new version) REMOVE=ALL is also true during uninstalling the application, so the files will be deleted.
You need to additionally check if the UPGRADINGPRODUCTCODE is also set or not, which would only be true during an update.

检查这个答案,其中给出了正确的条件(并像我一样将问题加入书签,这非常非常有用对于所有可能的状态和条件;-))

Check this answer where the correct condition is given (and bookmark the question as I did, it is very very useful for all the possible states and conditions ;-)).

在您的情况下,正确的条件应如下所示:

The correct condition should be the following in your case:

<InstallExecuteSequence>
  <Custom Action="Cleanup_logfile" Before="RemoveFiles" >
    (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
  </Custom>
</InstallExecuteSequence>

这篇关于WiX 卸载时删除文件但不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆