Skip to content
⌘ NSIS Forum Archive

Excluding OutFile

8 posts

cchen100#

Excluding OutFile

I don't like NSI script included in the extracted files. So I excluded *.nsi. No problem.
Then I wanted to remove the output file from the extracted files because if an user run it again from the installed location and select the same destination, it will crash when extracting the included output file. So I excluded it from the File instruction.

The compiler complained 'No file found' after 'File: Returning to: "." ' because in the "." directory, I have only the *.nsi and the OutFile. I had to put a dummy file in the "." directory to make it work.

Another issue, before I used a dummy file to exclude OutFile successfully, is when I had a.exe in "." directory as the OutFile, I renamed it to b.exe in order to preserve the last output file. The result is the script didn't follow the OutFile in the script, a.exe, anymore. The output file became b.exe.

I tried both v2.46 and v3.0b1.
cchen100#
OutFile name change?

You are right. My bad. I couldn't reproduce the symptom I thought I saw.
I guess what happen was the compiler packs OutFile, too. So when I saw the compiler packing the renamed EXE file, I thought the OutFile name was changed. And the real OutFile was not produced due to "Internal Compiler Error" So when I saw the specified OutFile was not in the directory, I thought OutFile was changed. Anyway, packing files in "." directory was unexpected. That's why I had such confusion.
In the following output of the compiler, test.exe was the OutFile, test-1.exe was the renamed file, and test.txt was the dummy file.

.
.
.
File: "test-1.exe" [compress] 21968/35510 bytes
File: "test.exe" [compress] 44948/57487 bytes
File: "test.txt" [compress] 0/597 bytes
File: Returning to: "."
SectionEnd
JasonFriday13#
Are you using something like this:
File /r "*.*"
This isn't the correct way to include files recursively in an installer. Usually you put all the files you need into a folder, then you include from that folder:
File /r "sourcefolder\*.*"
This prevents files in the top dir from being included, which is what your problem was.
cchen100#
File /r issue

I had the files in c:\source folder
then I used the script
File /r /x *.nsi /x OutFile "c:\source folder\"*.*
Other than the ' " ', it was almost exactly what you said.
Now I tried
File /r /x *.nsi /x OutFile "c:\source folder\*.*"
and it didn't get into the NSIS directory.

Interesting. Thanks,
JasonFriday13#
What I mean is that nsis scripts can use relative paths, so that you don't have to provide an absolute path.

So where ever the script file is, in the same directory put a source folder with your files and use a relative path. This way you don't have to use '/x *.nsi /x Outfile' because you are pointing at the source folder, not the same folder the .nsi is in. This also means you can move the .nsi and source folder to different directories and it will still compile.
cchen100#
Excluding OutFile

I think you missed the point. '/x' is not necessary anymore after I can avoid it getting into "." directory.

The point is:

File /r "c:\source folder\"*.*

is supposed to behave the same as

File /r "c:\source folder\*.*"

but it didn't. Am I wrong?
JasonFriday13#
Yes, you are wrong. That first line indicates that you want to add the folder to the installer, while the second line adds all the files within that folder.

If you look at the extracted files for each, you will see what I mean.