Passing in version number to Inno Setup compiler - inno-setup

I want my Inno Setup script to be build using the command line, and I want to pass in the product version number as a parameter. I am trying to implement it like so:
[setup]
VersionInfoVersion={param:version|0.0.0.0}
However the compiler informs me this is invalid for that directive. I have read this post on how to pass in custom parameters from the command line and assume I should just be able to pass in something like:
compil32 /cc "c:\isetup\samples\my script.iss" /version=1.0.0.0
I have also tried the suggestion from this post and tried doing the following:
#define PathToMyBinary "C:\bin\x64\Release"
#define ApplicationVersion GetFileVersion('#PathToMyBinary\MyBinary.dll')
VersionInfoVersion={#ApplicationVersion}
But it doesn't seem to return anything. Both approaches seem valid to me so I'm hoping someone can explain where I am going wrong.

Assuming you define the version via a pre-processor variable like:
[Setup]
VersionInfoVersion={#ApplicationVersion}
To set the version on a command-line, you have to use the ISCC.exe command-line compiler and its /D switch:
ISCC.exe Example1.iss /DApplicationVersion=1.2.3.4
If you want to provide a default value for the version, so the script can compile even without defining the variable on the command line, use #ifndef at the top of the script:
#ifndef ApplicationVersion
#define ApplicationVersion "1.2.3.4"
#endif
To read the version from a binary, you are correctly using the GetFileVersion pre-processor function.
But your syntax to make up the path is wrong.
A correct syntax is PathToMyBinary + '\MyBinary.dll', like:
#define PathToMyBinary "C:\bin\x64\Release"
#define ApplicationVersion GetFileVersion(PathToMyBinary + '\MyBinary.dll')
See Inno Setup Preprocessor: Expression Syntax.

After looking at many different options I found that this worked for me.
This is the command line to compile the setup file
"C:\Program Files (x86)\Inno Setup 5\iscc.exe" "MySetup.iss" /DVersion=1.2.3.4
In the setup file I added these lines, the first lines are to enable you to still run the script in the editor and ensure you would not get the error: Undeclared identifier: "Version"
#ifndef Version
#define Version = '0.0.0.0';
#endif
[Setup]
VersionInfoVersion={#Version}

In order to get my setup script (iss file) to work, I had to remove the #define ApplicationVersion line from my script. Once I did that, it recognized my /DApplicationVersion=8 input parameter.
"C:\Program Files (x86)\Inno Setup 5\iscc.exe" "install.iss" /DApplicationVersion=8

Related

Require minimum Inno Setup compiler version

I was wondering whether it's possible to print a custom error message in case someone tries to compile an .iss file with an unsupported Inno Setup version. This would be more helpful than for example having the compiler tell you "the WizardStyle directive isn't known" (or something like that). I've checked the "constants" section of the documentation, but couldn't find the compiler version number there.
Use preprocessor and its Ver predefined variable and #if and #error directives. Actually the documentation of the #error directive shows exactly the code you need:
#if VER < EncodeVer(5,4,2)
#error A more recent version of Inno Setup is required to compile this script (5.4.2 or newer)
#endif

Inno Setup can't find image files using mask on AppVeyor

We have a OSS project and I'm trying to upgrade to Inno Setup 6.0.5. When I compile the build script locally, it works as expected. However, when I try to build it via AppVeyor, it can't find the files. I've tried both:
using full path (this was working with 5.6.1):
#define BuildDir ExtractFileDir(ExtractFileDir(SourcePath)) + "\bin\"
#define IncludesDir SourcePath + "Includes\"
#define GraphicsDir SourcePath + "Graphics\"
...
WizardSmallImageFile={#GraphicsDir}Rubberduck.Duck.Small.55x55.bmp, \
{#GraphicsDir}Rubberduck.Duck.Small.64x68.bmp, \
{#GraphicsDir}Rubberduck.Duck.Small.83x80.bmp, \
{#GraphicsDir}Rubberduck.Duck.Small.92x97.bmp, \
{#GraphicsDir}Rubberduck.Duck.Small.110x106.bmp, \
{#GraphicsDir}Rubberduck.Duck.Small.119x123.bmp, \
{#GraphicsDir}Rubberduck.Duck.Small.138x140.bmp
WizardImageFile={#GraphicsDir}Rubberduck.Duck.164x314.bmp, \
{#GraphicsDir}Rubberduck.Duck.192x386.bmp, \
{#GraphicsDir}Rubberduck.Duck.246x459.bmp, \
{#GraphicsDir}Rubberduck.Duck.273x556.bmp, \
{#GraphicsDir}Rubberduck.Duck.328x604.bmp, \
{#GraphicsDir}Rubberduck.Duck.355x700.bmp
using wildcards:
#define BuildDir ExtractFileDir(ExtractFileDir(SourcePath)) + "\bin\"
#define IncludesDir SourcePath + "Includes\"
#define GraphicsDir SourcePath + "Graphics\"
#define WizardImageFilesDir GraphicsDir + "WizardImageFiles\"
#define WizardSmallImageFilesDir GraphicsDir + "WizardSmallImageFiles\"
...
WizardSmallImageFile={#WizardSmallImageFilesDir}Rubberduck.Duck.Small.*.bmp
WizardImageFile={#WizardImageFilesDir}Rubberduck.Duck.*.bmp
The files exist at the expected location, and are valid bitmaps. However, on AppVeyor we get this error:
Creating output directory: C:\projects\rubberduck\Rubberduck.Deployment\InnoSetup\Installers
Reading file (LicenseFile)
Reading file (WizardImageFile)
File: C:\projects\rubberduck\Rubberduck.Deployment\InnoSetup\Graphics\WizardImageFiles\Rubberduck.Duck.*.bmp
Error on line 81 in C:\projects\rubberduck\Rubberduck.Deployment\InnoSetup\Rubberduck.Installer.Build.iss: Could not read "C:\projects\rubberduck\Rubberduck.Deployment\InnoSetup\Graphics\WizardImageFiles\Rubberduck.Duck.*.bmp".
Error: The filename, directory name, or volume label syntax is incorrect.
Compile aborted.
We install Inno Setup using Chocolately. We found that we had to explicitly specify the version; otherwise, it'd use 5.5.9 instead of 6.0.5:
Original:
- cinst innosetup -version 5.6.1
Modified:
- cinst innosetup --version=6.0.5
Full AppVeyor console output (includes several pragma message) can be seen here.
Full ISS build script can be seen here.
Full Appveyor YML can be seen here.
Why would it work locally but fail on Appveyor?
Although you claim otherwise, you are still using 5.5.9:
Compiler engine version: Inno Setup 5.5.9 (u)
Wildcards in Wizard*ImageFile directives are supported since Inno Setup 5.6 only.
Though your script seems to install 6.0.5. As it is a different major version, it's in a different path, C:\Program Files (x86)\Inno Setup 6\ rather than C:\Program Files (x86)\Inno Setup 5\. AppVeyor comes with 5.5.9 preinstalled, which is probably, why, when time comes to run the build script, 5.5.9 gets executed instead. Try using the full path to the iscc to ensure, that you are running the correct major version of Inno Setup.

"File does not exist" error in Inno Setup when using {src} in Source

I have a problem when defining a file in the Inno Setup Files section. Some times when I use {src} constant and compile it I get an error that says the file doesn't exist.
Source: "{src}\dontReadMe.txt"; DestDir: "{tmp}";
And here is what I get:
That happened more when I use Flags dontcopy;.
Look at {src} in the path why it's there.
As the documentation for Source parameter says:
Constants may only be used when the external flag is specified, because the compiler does not do any constant translating itself.

Visual Studio Code-Cannot open source file "iostream"

I just want to try c++ coding with Visual Studio code. I have installed vscode 1.18.1 to my laptop (Win10-64).
I got errors by typing following code:
#include <iostream>
using namespace std;
int main()
{
std::cout << "Hello world!" <<endl;
return 0;
}
Should happen no Error. C:\Users\Harri\OneDrive\Tiedostot\Demo2.vscode\c_cpp_properties.json -content:
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
Problems/Errors for row 1:
" #include errors detected. Please update your includePath. IntelliSense features for this translation unit (C:\Users\Harri\OneDrive\Tiedostot\Demo2\Calc.cpp) will be provided by the Tag Parser. "
" cannot open source file "iostream" "
The main problem is cygwin paths
You have cygwin paths like /usr/include in your c_cpp_properties.json file. That is a problem because VSCode does not understand cygwin paths. At a cygwin shell you can run:
$ cygpath -w /usr/include
D:\cygwin64\usr\include
to get the equivalent Windows path. Put that into c_cpp_properties.json instead. Remember that you have to double the backslashes when you copy this into a JSON string.
Other suggestions
This SO answer describes how to set up VSCode with cygwin gcc. I haven't tried those instructions but they look reasonable.
Beyond that, I highly recommend going through the Get Started with C++ tutorial on the VSCode site. It might directly answer your question, but even if it doesn't, having a working setup to compare to is valuable.
Also, look at the C/C++ diagnostics: View → Command Palette... → C/C++: Log Diagnostics. This will show things like which compiler VSCode is trying to emulate and what it thinks the #include paths are.
Finally, to get lots of useful information directly from your compiler to compare with what VSCode thinks, if you are using gcc, run at a cygwin or bash prompt:
$ touch empty.c
$ gcc -v -E -dD empty.c > compiler-info.txt
That will write to compiler-info.txt all the predefined macros, #include search paths, default target, etc.
For some reason iosteam is a typo
Try using instead. It worked for me.
Working Code Screenshot

NDK APP_CFLAGS can't handle <> characters?

I am including a procedurally generated file into code used by several libraries, using something like
#include MY_CONFIG_FILE_H
Then I am attempting to set this value in my Application.mk using the following directive
APP_CFLAGS += -DMY_CONFIG_FILE_H=<Config/MyFile.h>
however, this results in ndk-build not finding the path. It fails right away on the first file it tries to compile
"Compile++ thumb : MyLibraryName <= MyFirstFile.cpp
The system cannot find the path specified.
make: *** [obj/local/armeabi-v7a/objs/MyLibraryName/MyFirstFile.o] Error 1
Indeed, the file is not there, but it did manage to create the file path. There must be some strange/inconsistent string manipulation going on.
Any ideas? Work arounds? Is this a known issue in ndk-build.cmd? For the record I'm on Windows x64 and NDK R9.
Also notice that if I only include > and no <, I get a different error
The filename, directory name, or volume label syntax is incorrect.
Changing the line to
APP_CFLAGS += -DMY_CONFIG_FILE_H="<Config/MyFile.h>"
worked. Hope this helps anyone else!

Resources