Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails without clear warning/error on processing !system command #40

Open
jantograaf opened this issue Jun 3, 2022 · 8 comments
Labels

Comments

@jantograaf
Copy link

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

  1. 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}'
  1. 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:

image

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'.

{34B9F9F9-7FD6-48C7-8E6E-211F945F82C6}

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)

@idleberg
Copy link
Owner

idleberg commented Jun 4, 2022

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 CertUtil located, locally or is it exposed in your PATH?
  • 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: #29

@jantograaf
Copy link
Author

  • CertUtil is exposed in the system's PATH , 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

{C7A05E59-BD51-406F-91C6-24204B2B9D08}

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.

@idleberg
Copy link
Owner

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.

@idleberg idleberg added the bug label Sep 8, 2022
@jantograaf
Copy link
Author

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:
image

@ShadowDrakken
Copy link

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.

@ShadowDrakken
Copy link

Also worthy of note, !appendfile works fine, so it's not running in the wrong mode (PPO). Only !system is failing out.

@idleberg
Copy link
Owner

idleberg commented Nov 22, 2023

@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:

  1. I'm compiling on macOS 12.7
  2. 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)

@ShadowDrakken
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants