vscode-nsis
vscode-nsis copied to clipboard
Compilation fails without clear warning/error on processing !system command
Description
Compilation using the NSIS Extension in VS Code fails on processing a !system compile-time command. My script is trying to calculate some files' checksums on compilation time so it can later on see if it downloads those files from a server correctly by checking it.
Steps to Reproduce
- Use the following code to calculate a checksum of a file, store that in a txt and then use that txt to populate a 'define' for later use
!system 'CertUtil -hashfile "C:\TMP\PutAnyFileNameHere.exe" MD5 | find /i /v "md5" | find /i /v "certutil" > C:\TMP\TOOLKITHASH.TXT'
!define /file TOOLKITHASH "C:\TMP\TOOLKITHASH.TXT"
!echo 'Toolkit hash seems to be : ${TOOLKITHASH}'
- Compile (strict or non-strict)
Expected behavior:
Compilation should calculate the MD5-checksum of the file, write it to the txt file and then load the content of that txt-file into the define named ${TOOLKITHASH}. It should then, for debugging purposes, echo the checksum to the output terminal.
The expected output should be (for the file I'm testing)
!system: "CertUtil -hashfile "C:\SVNBuild\1.0 VSOL Toolkit\0.0.0 VSTKInstallers\VSOL6Tools-Installer-v1.0.17.exe" MD5 | find /i /v "md5" | find /i /v "certutil" > C:\TMP\TOOLKITHASH.TXT"
!system: returned 0
!define: "TOOLKITHASH"="a79ae1f0fa63bf966bbab725b1fba56d"
Toolkit hash seems to be : a79ae1f0fa63bf966bbab725b1fba56d
MakeNSIS does it correctly for this script, without warnings or errors:

Actual behavior:
Compilation fails without clear error on the first !system command. Verbosity is set to 4 in the settings, diagnostics preprocess mode is set to 'none'.

Reproduces how often:
100 % of the time.
Versions
OS: Windows 10 v20H2 Build 19042.685 VS Code: 1.67.2 NSIS: v3.08 NSIS Extension: v3.49.0 (there was an issue with 3.50 which prevented anything from compiling so I rolled back the install yesterday)
Is there really no error message in either the default output pane or the developer console? It's a bit difficult to debug without knowing more about your setup, so maybe you could answer the following questions:
- Where is
CertUtillocated, locally or is it exposed in yourPATH? - How did you start VSCode? Does it behave differently when started from the command-line?
I also wonder, if this is related to this unresolved issue: https://github.com/idleberg/vscode-nsis/issues/29
CertUtilis exposed in the system'sPATH, I have just confirmed it to be working on every location on the PC.- VSCode is always started by a shortcut that runs it 'as Administrator', so it has all necessary permissions on the system

Regarding unresolved issue #29 , I have encountered similar issues in the same code I referred above. The following line will always throw an error during preprocessing:
!define /file TOOLKITHASH "C:\TMP\TOOLKITHASH.TXT"
However, when running it with MakeNSIS, all compiles fine. The reason for this behaviour is that the pre-processor seems to be checking if the file that is referenced (located in the C:\TMP-folder) actually exists. Which it should not do, in my case, since it is created and populated by the previous !system line.
The reason for this behaviour is that the pre-processor seems to be checking if the file that is referenced
Are you talking about the PPO flag of makensis? That one is only used in the Diagnostics feature, unless you specified it as a custom argument.
Hi @idleberg , excuses for reviving this old issue, but today I ran into it again and I have no option to circumvent it this time.
Because of changes in our build environment / Jenkins setup, I need to load specific tools/data from a location that is saved in the system's environment variables. The following code works perfectly when ran from makensis but does not when ran from VS Code. Latest version of all NSIS plugins, path to makensis is set correctly, all other scripts still build fine:
!define REPOLOCATION "$%REPOSITORY_LOCATION%"
!define RELEASELOCATION "$%RELEASE_LOCATION%"
!define /file SHORTVERSION "${REPOLOCATION}\jg-toolkit\1.0 VSOL Toolkit\0.0.0 VSTKInstallers\ShortVersionV6.txt"
!define VERSION ${SHORTVERSION}.0
This throws the following error (even though the file exists in that repository location):
!define /file: file not found ("$%REPOSITORY_LOCATION%\jg-toolkit\1.0 VSOL Toolkit\0.0.0 VSTKInstallers\ShortVersionV6.txt")
Error in script "d:\Repositories\jg-toolkit\1.0 VSOL Toolkit\0.0.0 VSTKInstallers\VSOL Toolkit Installer - VSOL6.nsi" on line 8 -- aborting creation process
Behaviour does not change when code.exe is launched from command line. It also marks the line as containing an error:
I'm encountering this same issue. It seems to happen with ANY calls to !system, not just file actions. For example: !system "echo Hello World!"
Works fine in MakeNSISW, but dies as soon as it hits the !system line in VSCode with no errors being reported.
Also worthy of note, !appendfile works fine, so it's not running in the wrong mode (PPO). Only !system is failing out.
@ShadowDrakken So the following script does not work for you?
Script
!system "echo 'Hello World'"
OutFile "demo.exe"
Unicode false
Section
SectionEnd
Output
MakeNSIS v3.09 - Copyright 1999-2023 Contributors
See the file COPYING for license details.
Credits can be found in the Users Manual.
Processing script file: "/Users/idleberg/Desktop/demo.nsi" (UTF8)
Hello World
Processed 1 file, writing output (x86-ansi):
Output: "/Users/idleberg/Desktop/demo.exe"
Install: 1 page (64 bytes), 1 section (4120 bytes), 1 instruction (28 bytes), 23 strings (284 bytes), 1 language table (194 bytes).
Using zlib compression.
EXE header size: 36864 / 38400 bytes
Install code: 405 / 2010 bytes
Install data: 0 / 0 bytes
CRC (0x773607A3): 4 / 4 bytes
Total size: 37273 / 40414 bytes (92.2%)
However, take note of the following two things as they might have a impact:
- I'm compiling on macOS 12.7
- I can't use Unicode due to a known bug
Would you be so kind and compile the script as-is and with Unicode true (removing the line should have the same effect)
Happens on both Windows 10 and Windows 11 with Unicode set to either true or false. I've set the Verbosity to 4, otherwise it just dies after the header with no information at all
MakeNSIS v3.09 - Copyright 1999-2023 Contributors
See the file COPYING for license details.
Credits can be found in the Users Manual.
Processing config: D:\Program Files\NSIS\nsisconf.nsh
Processing default plugins: "D:\Program Files\NSIS\Plugins\x86-unicode\*.dll"
+ AdvSplash::show
+ Banner::destroy
+ Banner::getWindow
+ Banner::show
+ BgImage::AddImage
+ BgImage::AddText
+ BgImage::Clear
+ BgImage::Destroy
+ BgImage::Redraw
+ BgImage::SetBg
+ BgImage::SetReturn
+ BgImage::Sound
+ Dialer::AttemptConnect
+ Dialer::AutodialHangup
+ Dialer::AutodialOnline
+ Dialer::AutodialUnattended
+ Dialer::GetConnectedState
+ InstallOptions::dialog
+ InstallOptions::initDialog
+ InstallOptions::make_unicode
+ InstallOptions::show
+ LangDLL::LangDialog
+ Math::Script
+ NSISdl::download
+ NSISdl::download_quiet
+ Splash::show
+ StartMenu::Init
+ StartMenu::Select
+ StartMenu::Show
+ System::Alloc
+ System::Call
+ System::Copy
+ System::Free
+ System::Get
+ System::Int64Op
+ System::Store
+ System::StrAlloc
+ TypeLib::GetLibVersion
+ TypeLib::Register
+ TypeLib::UnRegister
+ UserInfo::GetAccountType
+ UserInfo::GetName
+ UserInfo::GetOriginalAccountType
+ VPatch::GetFileCRC32
+ VPatch::GetFileMD5
+ VPatch::vpatchfile
+ nsDialogs::Create
+ nsDialogs::CreateControl
+ nsDialogs::CreateItem
+ nsDialogs::CreateTimer
+ nsDialogs::GetUserData
+ nsDialogs::KillTimer
+ nsDialogs::OnBack
+ nsDialogs::OnChange
+ nsDialogs::OnClick
+ nsDialogs::OnNotify
+ nsDialogs::SelectFileDialog
+ nsDialogs::SelectFolderDialog
+ nsDialogs::SetRTL
+ nsDialogs::SetUserData
+ nsDialogs::Show
+ nsExec::Exec
+ nsExec::ExecToLog
+ nsExec::ExecToStack
!define: "MUI_INSERT_NSISCONF"=""
Changing directory to: "d:\NSIS\"
Processing script file: "d:\NSIS\demo.nsi" (ACP)
!system: "echo 'Hello World'"
And just dies there. No errors and the MakeNSIS process is gone