首页 > 解决方案 > nsis 中的组件共享文件

问题描述

我有 4 个 nsis 组件,它们有几个共享文件,每个都有不同的文件夹。

如何包含共享文件并将它们复制到选定的组件文件夹中?通常,如果我将共享文件与文件一起包含在一个部分中,那么我将在安装程序中有重复的文件,并且安装程序会很重。

我可以为这个问题做些什么?

标签: nsis

解决方案


As far as I understand it, the SetDatablockOptimize instruction will optimize the installer and not include duplicate files.

This command tells the compiler whether or not to do datablock optimizations. Datablock optimizations have the compiler check to see if any data being added to the data block is already in the data block, and if so, it is simply referenced as opposed to added (can save a little bit of size). It is highly recommended to leave this option on.

Apart from that, you could always use functions that extract the files and change the output path before calling those functions.

Section
  SetOutPath "first_path"
  Call ExtractBaseFiles

  SetOutPath "second_path"
  Call ExtractBaseFiles
SectionEnd

Function ExtractBaseFiles
  File "first_file"
  File "second_file"
FunctionEnd

推荐阅读