不存在但将被创建的 NSIS 副本文件

NSIS copy file that doesn't exist but will be created

我正在尝试从一开始不存在但会在复制前创建的文件夹中复制文件。

Name "Test Installer"
OutFile "testinstaller.exe"
InstallDir C:\dev\NSIS\Scripts\Testinstaller

Section "copyTest"
    SetOutPath $INSTDIR
    CreateDirectory $INSTDIR\test
    SetOutPath $INSTDIR\test
    File test2\test.txt
    SetOutPath $INSTDIR
    File /nonfatal test\test.txt
SectionEnd

问题是编译器在尝试编译时创建错误,找不到文件。但是当编译前创建的文件编译后删除时程序有效。

File command includes a file into your installer, hence it must exist at compile time. You can CopyFiles在运行时复制文件。