Using Regex in install4j Compiler Variable - install4j

During installation, install4J looks for a certain file format to load (and later extract). The file format is the following:
server_${compiler:component_name}_${compiler:modality_version}_${compiler:modality_os}_BN${compiler:timestamp}.tar.gz
Everything works except for the last compiler variable which is the timestamp. I would like that variable to be a regex:
([0-9]{4})(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])(2[0-3]|[01][0-9])([0-5][0-9])
However, install4j is unable to figure out that what I'm giving it is a regex and not hard-coded variable.
How can I resolve this?
Currently, I'm getting this during the build:
[INFO] [WARNING] The path "..\..\target\resources\archives\server_merch_4.1_SP1_win-x86-64_BN([0-9]{4})(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])(2[0-3]|[01][0-9])([0-5][0-9]).tar.gz" does not exist.
If this is not possible, is there a way I can use the wildcard "*"?

There is no ad-hoc regex pattern matching like that in install4j.
Use a "Set a variable" action where you list files yourself and write the matching file to an installer variable. In the action that reads the file you can then use the expression ${installer:myVariable} where myVariable is the variable name configured in the "Set a variable" action.

Related

How to specify the AdditionalLibraryDirectories to msbuild?

I'm dealing with a .vcxproj file with the following Link segment:
<Link>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AssemblyDebug>
</AssemblyDebug>
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
It would seem, I should be able to add more elements to the linker's LIBPATH by simply adding one more argument to msbuild's command line: /p:AdditionalLibraryDirectories=D:\Foo\lib. Unfortunately, this seems ignored and link.exe is invoked with only the /LIBPATH:..\lib argument...
If I edit the file and replace the %(AdditionalLibraryDirectories)-part with the desired path, things work -- linker is invoked with two /LIBPATH: arguments and the executable gets built.
Why can't I specify it as property on command-line, though?
I'm using Visual Studio 2017, with msbuild announcing itself as "Build Engine version 15.9.21+g9802d43bc3".
You'll need to use a completely separate MSBuild property.
For example, on your command line:
msbuild ... /p:FooLibDir=..\lib
and in the project file:
<AdditionalLibraryDirectories>$(FooLibDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
The reason that setting AdditionalLibraryDirectories on the command line doesn't work, is that the /p command line option for MSBuild sets properties, whereas AdditionalLibraryDirectories is metadata on the Link item (note how the parent of the AdditionalLibraryDirectories tag is a Link tag, not PropertyGroup).
The way to think about the difference is:
A property is a global variable accessible to everything (hence it can be set on the command line).
Metadata is specific to a single item (e.g., what additional directories to search for libs in, when linking this specific .obj).
Metadata in a ItemDefinitionGroup becomes a "template" that each instance of that item will use when declared.

Can't access build variables from powershell script

I'm trying to use the Build variables in a script. According to this documentation I should be able to use the following:
Write-Host "BUILD_DATE: $Env:BUILD_DATE"
Write-Host "BUILD_REV: $Env:BUILD_REV"
However, I only get the following output
BUILD_DATE:
BUILD_REV:
I've also tried this syntax:
Write-Host "BUILD_DATE: $(Env:BUILD_DATE)"
Write-Host "BUILD_REV: $(Env:BUILD_REV)"
Write-Host "BUILD_DATE: $(Build.Date)"
Write-Host "BUILD_REV: $(Build.Rev)"
But the first segment gives The term 'Env:BUILD_DATE' is not recognized and the second segment gives The term 'Build.Date' is not recognized
How can I use the build variables in my script?
Disclaimer: I know virtually nothing about Azure pipelines, so my answer is based on reading the docs. Do let us know if I got things wrong.
Your first command uses the correct syntax for referencing environment variables in PowerShell (also inside an expandable (double-quoted) string).
(The other commands, based on subexpression operator $(...), mistakenly try to execute commands named Env:BUILD_DAT, ... rather than referencing variables.)
Your problem seems to be that the targeted environment variables do not exist.
The list of predefined variables that are exposed as environment variables does not contain variables named Build.Date / $env:BUILD_DATE and Build.Rev / $env:BUILD_REV.
By contrast, variables named Date and Rev seemingly do exist - as you state, they are used in the default format definition for the Build.BuildNumber / $Env:BUILD_BUILDNUMBER build variable, $(Date:yyyyMMdd)$(Rev:.r) - but are seemingly of a different kind not exposed as env. vars. (unlike Build.BuildNumber / $Env:BUILD_BUILDNUMBER itself, which is exposed).
(I don't know where these variables are defined or how they are classified, and where this is documented - do tell us if you know.)
A quick workaround would be to split the value of $Env:BUILD_BUILDNUMBER into its constituent parts:
# Split the build number into date and revision, by "."
$date, $rev = $Env:BUILD_BUILDNUMBER -split '\.'
"BUILD_DATE: $date"
"BUILD_REV: $rev"

Folder name with space issue

How do I handle a folder name containing spaces in Perl? For example C:\Sample Picture\Data.
I wrote this
use File::Glob ':glob';
$indir = "C:\\Sample Picture\\Data\\";
#flist = bsd_glob( $indir.'*');
This is throwing an error
The syntax of the command is incorrect.
The error message The syntax of the command is incorrect comes from the Windows command line, not from Perl
The issue is not to do with File::Glob, but with whatever you are doing with the contents of #flist. It's my guess that you're using backticks or system to rename one or more of the files or directories. This will fail if you use paths that contain spaces without enclosing the complete path in double quotes
If you need any more help then you must show the relevant part of your code

Passing Parameters in MS Web Deploy Command Line Deployment

I used msbuild to build a deployment package for my website. I am trying to use the generated deploy.cmd file located in the package to deploy to a remote server. I am using web deploy's parameters and I would like to set these at the command line using the -setParam flag.
The usage instructions for WebDeploy indicate that I need to enclose the -setParam configuration option in quotation marks because it contains an '=' character. However, the deploy.cmd file passes the entire option, including quotation marks, to the msdeploy executable. The msdeploy executable fails to run because the option does not start with the "-" character.
Error: Unrecognized argument '"-setParam:TestParam=ABC123"'. All arguments must begin with "-".
What do I need to do in order to get the setParam call working with the cmd file generated by msBuild?
Have successfully used -setParam option in the following syntax, enclosing entire option in double quotes, and dubling double quotes inside:
...deploy.cmd "-setParam:name=""IIS Web Application Name"",value=""example.com"""
You don't need to wrap the entire parameter in quotes because of the equals sign. Just the parameter key and value because it may contain spaces.
-setParam:"TestParam"="ABC123"
should work for your example. Or in real world:
-setParam:"IIS Web Application Name"="example.com"

xcode build version number in shell script

I have an user-defined Project setting (KEY/VALUE) like this:
LATEST_BUILD_NUMBER 2.2.2.2
In my Info.plist, I have set the bundle version (CFBundleVersion) key/value pair like this
Bundle version ${LATEST_BUILD_NUMBER}
I am creating a shell script to do the builds for my all of my targets. I want to fetch the value "2.2.2.2" in my script. This is what I tried:
INFO_PLIST_FULL_PATH="${PROJDIR}/${TARGET_NAME}-Info.plist"
echo plist path ${INFO_PLIST_FULL_PATH}
TARGET_BUILD_VERSION_NUMBER=$(/usr/libexec/PlistBuddy -c "Print ${BUILD_NUMBER}" $INFO_PLIST_FULL_PATH)
echo version_number ${TARGET_BUILD_VERSION_NUMBER}
When I do this, the output for plist path is correct but TARGET_BUILD_VERSION_NUMBER output is "${LATEST_BUILD_NUMBER}" instead of "2.2.2.2"
How can I get the value instead of the variable name?
Xcode doesn't substitute the value till it copies over the file into the built product. So, go to the source: Grab the value out of the *.xcodeproj/project.pbxproj file. You should be able to find the current value in there with a quick search. Then you just have to devise a regex to strip it out.