Docker build for Matlab Compiler Runtime on Windows (non-interactive installation) - powershell

I notice that some steps in the Docker build takes more time than manually executing the same command in the container. To provide some context, the process of installing Matlab Compiler Runtime (MCR) is as follows:
Download MCR installer from MathWorks website
Unpack installation files
Run /bin/win64/setup.exe -mode silent -agreeToLicense yes (non-interactive install)
I created the following Dockerfile to set up MCR on a Microsoft windowsservercore image including dotnet-framework.
# Line 1: Use dotnet-framework base image
FROM microsoft/dotnet-framework
# Line 2: Download MCR installer (self-extracting executable) and save as ZIP file
ADD https://www.mathworks.com/supportfiles/downloads/R2014b/deployment_files/R2014b/installers/win64/MCR_R2014b_win64_installer.exe C:\\MCR_R2014b_win64_installer.zip
# Line 3: Use PowerShell
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# Line 4: Unpack ZIP contents to installation folder
RUN Expand-Archive C:\\MCR_R2014b_win64_installer.zip -DestinationPath C:\\MCR_INSTALLER
# Line 5: Run the setup command for a non-interactive installation of MCR
RUN Start-Process C:\MCR_INSTALLER\bin\win64\setup.exe -ArgumentList '-mode silent', '-agreeToLicense yes' -Wait
# Line 6: Remove ZIP and installation folder after setup is complete
RUN Remove-Item -Force -Recurse C:\\MCR_INSTALLER, C:\\MCR_R2014b_win64_installer.zip
I build a new image using the command:
docker build -t analytics/dotnet-mcr --no-cache --force-rm .
The installation of MCR is very slow, when compared to stopping at Line 4 and then manually running the MCR setup from a container based on the ensuing image (using the exact same PowerShell command)... any reason why needs an extra 3-4 minutes when performing the same step via the Dockerfile based build?
Note: Best practices suggest using a download utility versus using ADD, but I don't have any constraints related to image size since I am removing intermediate images as well as deleting the downloaded installer and unpacked installation folder. Plus, I like seeing the cleaner download progress bar of the ADD command.
I appreciate any improvements/optimizations that may be suggested.

Docker uses layers. According to it documentation each RUN command will create a layer. In your scenario, each layer will store the data related to the RUN command, so removing MCR_R2014b_win64_installer.zip as separate step will cause extra space in previous layers. I would recommend reducing RUN commands where it is possible.
Please check repo for more help.

Related

Chocolatey Install Package Failing

For those who are familiar with creating Chocolatey packages, can someone offer help to why this one isn't working? It packs, but when I test (install only package), it won't work.
Here is the chocolateyinstall.ps1 file:
$ErrorActionPreference = 'Stop'; # stop on all errors
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$fileLocation = Join-Path $toolsDir 'armcc.exe'
$packagename = 'ARM_RVCT'
$packageArgs = #{
packageName = $packageName
unzipLocation = $toolsDir
fileType = 'EXE' #only one of these: exe, msi, msu
#url = $url
#url64bit = $url64
file = $fileLocation
softwareName = 'ARM_RVCT*' #part or all of the Display Name as you see it in Programs and Features. It should be enough to be unique
silentArgs = '/S' # ALLUSERS=1 DISABLEDESKTOPSHORTCUT=1 ADDDESKTOPICON=0 ADDSTARTMENU=0
validExitCodes= #(0)
}
Install-ChocolateyInstallPackage #packageArgs # https://chocolatey.org/docs/helpers-install-chocolatey-install-package
When I do choco pack and then run choco install arm_rvct, I get this output:
Installing the following packages:
arm_rvct
By installing you accept licenses for the packages.
arm_rvct v3.1
arm_rvct package files install completed. Performing other installation steps.
Installing ARM_RVCT...
Microsoft.PowerShell.Commands.WriteErrorException
Error: C3079E: armcc command with no effect
Error: C3065E: type of input file '/S' unknown
Microsoft.PowerShell.Commands.WriteErrorException
ERROR: Running ["C:\ProgramData\chocolatey\lib\arm_rvct\tools\armcc.exe" /S ] was not successful. Exit code was '1'. See log for possible error messages.
The install of arm_rvct was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\arm_rvct\tools\chocolateyinstall.ps1'.
See log for details.
Chocolatey installed 0/1 packages. 1 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Failures
- arm_rvct (exited 1) - Error while running 'C:\ProgramData\chocolatey\lib\arm_rvct\tools\chocolateyinstall.ps1'.
See log for details.
It tells you exactly what the problem is in the error message:
Error: C3079E: armcc command with no effect
Error: C3065E: type of input file '/S' unknown
First, it looks like you might be commenting out, or at the very least, not providing required parameters for armcc.exe. Second, it looks like /S in the context of armcc.exe isn't for a silent install - it wants an input file which you are not currently providing as part of your silent args.
armcc.exe isn't an installer btw - if you don't have a proper installer for your toolchain, consider putting the toolchain in a zip archive, embedding that zip in your package, and then install with Install-ChocolateyZipPackage instead of Install-ChocolateyInstallPackage (the latter is for installing exe or msi installers).
This should automatically generate some shims for your executables and place them on the path. Note that since this looks like it's for the arm_rvct compiler, if that normally accepts pipeline input, Chocolatey shims actually do not support pipeline input, so keep that limitation with generated shims in mind.
It does look like there is an official installer for the ARM toolchain. However, the installation instructions in the release notes don't provide any silent install instructions. That said, this is a common problem with undocumented installers - but it doesn't mean that you can't perform a silent install either, with some effort on your side.
You can either try running setup.exe /S or the referenced ARM Compiler 6.13.msi with msiexec /i "ARM Compiler 6.13.msi" /qn. If neither of these work, you have the options of reaching out to the vendor to ask how silent installs work, or you can go the route of taking the installed files and packaging them into a zip. Note that installers, especially for devkits and toolchains, may register assemblies in Windows and this can get complicated to reverse engineer if a simple file install doesn't work.
In this case though, the vendor would be the best resource to understand how you are able to deploy this package throughout your organization.

Silent Install Fails, Resultcode = -8 [Now ResultCode 0 but not installed]

I am trying to install a program silently (the program is old, has InstallShield v7.00). However, every time I run the command, it does nothing and the setup.log file states "ResultCode=-8".
That ResultCode indicates that an invalid path to the InstallShield Silent installation script file was specified (which I am assuming to be the response file I generated earlier, which is named setup.iss).
Setup.exe and setup.iss are both in the same folder. I tried specifying the exact path to both files, and not, as seen in the list of commands I have tried below:
"C:\Test\setup.exe" /s /f1"C:\Test\setup.iss"
setup.exe /s /f1 setup.iss (CMD directory is in C:\Test)
setup.exe /s (Thought it would just find the setup file automatically as they are in the same folder)
I am trying to install EPSON OPOS ADK, for which the installation manual states the exact commands I am using are correct.
There is no MSI file contained in the EXE file (or, if there is, I cannot extract it with WinRAR and I could not find it in ProgramData while the setup was running).
Does anyone know what I am doing wrong or what I can do?
EDIT: Below is the contents of my setup.iss file:
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-DlgOrder]
Dlg1={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdWelcome-0
Count=7
Dlg2={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdLicense2-0
Dlg3={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdSetupType-0
Dlg4={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdStartCopy-0
Dlg5={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-AskOptions-0
Dlg6={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdFinish-0
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdWelcome-0]
Result=1
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdLicense2-0]
Result=1
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdSetupType-0]
szDir=C:\Program Files (x86)\OPOS\Epson2
Result=301
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdStartCopy-0]
Result=1
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-AskOptions-0]
Result=1
Sel-0=1
Sel-1=0
Sel-2=1
Sel-3=0
[Application]
Name=EPSON OPOS ADK
Version=031.000.01000
Company=SEIKO EPSON CORPORATION
Lang=0009
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdFinish-0]
Result=1
bOpt1=0
bOpt2=0
EDIT 2:
So I ran the recording for the .iss file again, but this time instead of just doing "setup -r", I did "setup -r f1"C:\"" instead. This should make no difference other than telling it where to save the recording. However, I got a different .iss file out of it. Here it is:
[InstallShield Silent]
Version=v7.00
File=Response File
[File Transfer]
OverwrittenReadOnly=NoToAll
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-DlgOrder]
Dlg0={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-Uninstall-0
Count=7
Dlg1={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdWelcome-0
Dlg2={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdLicense2-0
Dlg3={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdSetupType-0
Dlg4={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdStartCopy-0
Dlg5={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-AskOptions-0
Dlg6={0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdFinish-0
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-Uninstall-0]
Uninstall=0
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdWelcome-0]
Result=1
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdLicense2-0]
Result=1
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdSetupType-0]
szDir=C:\Program Files (x86)\OPOS\Epson2
Result=301
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdStartCopy-0]
Result=1
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-AskOptions-0]
Result=1
Sel-0=1
Sel-1=0
Sel-2=1
Sel-3=0
[Application]
Name=EPSON OPOS ADK
Version=031.000.01000
Company=SEIKO EPSON CORPORATION
Lang=0009
[{0EEDEE2B-7C9D-4584-B2B5-C28C93678BC1}-SdFinish-0]
Result=1
bOpt1=0
bOpt2=0
I was very happy when I saw it was different, and figured my issue would be solved. Well, not exactly.
Now, instead of getting ResultCode = -8, I am getting ResultCode = 0. A code of 0 indicates there was a successful installation. However, the program did NOT install. Nothing was touched. I noticed this before even looking at the code because it finished "installing" almost immediately after running the command, with no loading icons or anything.
So now, InstallShield is reporting that the program was successfully installed but it, in actuality, was not. I tried re-recording the .iss file numerous more times but I am just getting this same file now. The file is likely no longer the issue. However, I am at a loss for what the issue could be now.
Setup.iss: I guess the real problem might be that there is an error in your setup.iss file. Can we see its content? Maybe the setup.iss you are using is for another Setup.exe entirely? Try re-generating a new one?
UPDATE: Maybe have a look here as well: Epson OPOS ADK for .NET drivers for Windows 7
That silent.iss response file seems to lack a header section when compared with this documentation: Performing Silent Installations and Uninstallations (PDF, section "InstallScript Installations" page 3 onwards).
Setup.exe Extract: Maybe also make sure that this is not an MSI setup after all:
Short version: Programmatically extract contents of InstallShield setup.exe
Long version: Extract MSI from EXE
And:
Extracting from an MSI (administrative installation).
How to deploy the Installshield MSI without having to run Setup.exe
Sample Setup.exe Command Lines: For inspiration an ancient Itninja / AppDeploy PDF with sample Installshield setup.exe commands (I think the last few entries in the document were never finished, they just all say Setup.exe /uninst - so just ignore them). Did you try the /SMS parameter? I don't see how that would solve your particular problem, but you should know about the switch anyway.
Some Links:
InstallShield Error Codes (Setup.log)
InstallShield Setup Silent Installation Switches
Performing Silent Installations and Uninstallations (PDF)
EPSON OPOS ADK for .NET Manual (PDF)
Installshield 2018 Help File:
Setup.exe and Update.exe Command-Line Parameters
Advanced UI and Suite/Advanced UI Setup.exe Command-Line Parameters
Setup.exe (InstallScript Projects)

How can I make a SSH tunnel command into a service on Windows 10?

I have a very simple command in powershell to start SSH tunnels:
ssh -N -L 28777:localhost:28778 myapp-db
What's the simplest way to make this a service, so I can run:
start-service db-tunnel
etc on Windows 10? I've read an old article on doing this and it involves using C#, which seems way too complex for such a simple task.
PowerShell is not necessary. Here's one way:
Install the Windows Server 2003 Resource Kit Tools package somewhere and get the files instsrv.exe and srvany.exe.
Use srvany.exe to create the service using the ssh.exe program and its parameters using the information in Microsoft help article 137890.
For example:
instsrv "SSH Server" "C:\Program Files (x86)\Resource Kit Tools\srvany.exe"
Of course, specify whatever service name you want and the path and filename of srvany.exe.
Next, use the registry editor to go to HKLM\SYSTEM\CurrentControlSet\Services\SSH Tunnel (or whatever you named the service) in the registry and create a Parameters subkey. In the Parameters subkey create an Application value (REG_SZ type):
C:\Program Files (x86)\ssh\ssh.exe
(or whatever - the path and filename to your ssh executable).
You can also create the values AppDirectory (REG_SZ) to specify the starting directory for the executable, and AppParameters (REG_SZ) to specify the parameters to the executable; e.g.:
-N -L 28777:localhost:28778 myapp-db
You can substitute the use of the NSSM tool mentioned by BenH in his comment if you prefer that tool and are allowed to use third-party software.
To make something into a service, you would need to compile your script into an executable. This can be done via PS2EXE.
What may work just as well for you is making a function in powershell, Start-DbTunnel, and making that import into your powershell session on start. You can do this by loading functions in the foloowing path:
$PSprofilePath\Microsoft.PowerShell_profile.ps1
or for the ISE
$PSprofilePath\Microsoft.PowerShellISE_profile.ps1
Inside those files, I have
$PSprofilePath = "C:\Users\cknutson\Documents\WindowsPowershell"
$items = Get-ChildItem "$PSprofilePath\functions"
#Set-Location "$PSprofilePath\functions"
$items | ForEach-Object {
. $_.FullName
}
Set-Location C:\
Any scripts containing functions, or otherwise will be run each time you open a powershell host.

Execute jar and display text in jenkins console log

I have abc.jar file to deploy and run in remote machine.
I have transferred the file using jenkins, now what I have done is, call a a.bat batch file on remote machine using psexec in Execute Windows Batch Command.
a.bat executes the abc.jar
When the jar begins execution, the command prompt texts are stored in a file.
using java -jar abc.jar >> a.log 2>&1
Now what I want is to display the a.log contents in the jenkins console when the jar file is being executed
(the file is continuously being written and I want to show it in jenkins console as it is being written)
I have tried to do it using parallel processing by calling start twice, one for calling batch file, another using type for displaying.
But when I use start I get Process leaked file descriptor .
Is there any other way I can achieve this. Be it calling powershell or scheduled task in jenkins.
You need to look for tee equivalents in windows , there are few like GNU utilities for Win32, however if you have cygwin you can still use tee which will easy the prcoess.
Now the wuestion arises how to run my jar file on cygwin from jenkins ?
you can still use execute windows[batch] shell. and add cygwin installation path to the PATH variable and start using linux command like a BOSS.
or you can use powershell tee in built command from batch.

Rename the Single .exe file name parameter using command line IsCmdBld.exe Installshield

How do I specify the name for the executable using the command-line version of Installshield. I'm looking for the command line switch
I need to create a package based on the version I pass.
For ex : If I pass - 2.2.0,
SET RELEASE_VERSION="2.2.0"
ISCmdBld.exe -p "\Path\BuildProject.ism" -y %RELEASE_VERSION% -? MY_COOL_APP_%RELEASE_VERSION%.EXE
I need to know the switch (indicated as ? here) which will create MY_COOL_APP_2.2.0.exe after building and running the command line InstallShield build tool.
I tried using the values from the path variables at build time
ISCmdBld.exe -p "\Path\BuildProject.ism" -y %RELEASE_VERSION% -l MYPathVar="MY_COOL_APP_%RELEASE_VERSION%"
I have associated the value of the path variable for the single .exe file in the Project-->Settings-->Application tab but still the build gives me the default setup.exe
Much appreciate your inputs
There is no parameter for IsCmdBld.exe that directly changes the name of the resulting setup.exe file. For a couple predetermined names you could make multiple release configurations and select them (with -r, or product configurations via -a), but for your case that is unlikely to scale. Instead you should consider one of the following:
Use automation (perhaps invoke a .vbs script) to edit the release configuration, and then build the project
Build to a known name, and then rename the resulting file as the next step in your build script