How to run aspnet_regiis.exe in a deferred custom action and pass the value of INSTALLDIR property? - installshield

I have a custom action (RunEncryption2) that I'm using for encrypting a configuration file by using aspnet_regiis.exe. The custom action type that I'm using is an EXE with path referencing a directory (initial type 34) using deferred execution in system context (so the final type is 3106). The file that I want to encrypt is on INSTALLDIR, so I have a Set Property custom action (SetRunEncryption2, type 51) where I'm setting RunEncryption2=[INSTALLDIR]. My two custom actions look like this:
SetRunEncryption2
Property Name: RunEncryption2
Property Value: [INSTALLDIR]
RunEncryption2
Working Directory: WindowsFolder
File Name & Command line: [WindowsFolder]Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef "connectionStrings" "[CustomActionData]" -prov "DataProtectionConfigurationProvider"
When the installer runs, I get no error, however the file gets no encryption at all. When I review the log, I get the following:
MSI (s) (34:C0) [17:32:11:356]: Executing op: CustomActionSchedule(Action=RunEncryption2,ActionType=3106,Source=C:\WINDOWS\,Target=C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef "connectionStrings" "" -prov "DataProtectionConfigurationProvider",CustomActionData=C:\Test\)
From the log I can see that the CustomActionData property has been set correctly, however it hasn't been included as part of the command.
At this point the only way I have to make the command work is passing a hard-coded value of INSTALLDIR, otherwise it doesn't seem to work.
I have tried:
Not using CustomActionData, instead passing the value of INSTALLDIR as part of my command line directly.
Using a "Path in Property value" custom action with similar results.
When I run option 1 above, I get a 1722 error on the log:
MSI (s) (C4:50) [12:49:46:968]: Note: 1: 1722 2: RunEncryption2 3: C:\WINDOWS\ 4: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef "connectionStrings" "C:\Test\" -prov "DataProtectionConfigurationProvider"
Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. Action RunEncryption2, location: C:\WINDOWS\, command: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef "connectionStrings" "C:\Test\" -prov "DataProtectionConfigurationProvider"
MSI (s) (C4:50) [12:49:56:841]: Product: TestEncryption -- Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. Action RunEncryption2, location: C:\WINDOWS\, command: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef "connectionStrings" "C:\Test\" -prov "DataProtectionConfigurationProvider"
Does anyone know how can I do to correctly execute this command and dynamically pass the value of INSTALLDIR?

Finally found the problem was not in the custom action passing the properties, but in the way that aspnet_iisreg is expecting the parameters.
INSTALLDIR is passing the string with a trailing slash (e. gr. c:\Test\), when I hard coded the installation path I was passing c:\Test instead.
The solution consisted in creating another custom action that removes the trailing slash and stores the value in a new property, this then can be used as parameter for aspnet_iisreg.
By the way, as Michael Urman mentioned, there was no need to use CustomActionData. Thanks.

Related

After updating ChefDK, I get the error "undefined local variable or method `credentials_file'" in Test Kitchen or an error in credentials.rb in knife

This issue was discovered after upgrading from ChefDK 3.2.30 to 4.2.0, and everything worked fine before the upgrade (Including these two commands).
The full error from "knife node list":
C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/rbvmomi-1.13.0/lib/rbvmomi/vim.rb:8: warning: Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead
Traceback (most recent call last):
8: from C:/opscode/chefdk/bin/knife:359:in <main>' 7: from C:/opscode/chefdk/bin/knife:359:inload'
6: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36-universal-mingw32/bin/knife:24:in <top (required)>' 5: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36-universal-mingw32/lib/chef/application/knife.rb:162:inrun'
4: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36-universal-mingw32/lib/chef/knife.rb:221:in run' 3: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36-universal-mingw32/lib/chef/knife.rb:440:inconfigure_chef'
2: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36-universal-mingw32/lib/chef/knife.rb:185:in load_config' 1: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-config-15.1.36/lib/chef-config/workstation_config_loader.rb:72:inload'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-config-15.1.36/lib/chef-config/mixin/credentials.rb:92:in load_credentials': undefined local variable or methodcredentials_file' for #<ChefConfig::WorkstationConfigLoader:0x000000000c311e68> (NameError)
The full error from 'kitchen converge':
------Exception-------
Class: Kitchen::ClientError
Message: Could not load the 'chef_zero' provisioner. Error: undefined local variable or method `credentials_file' for #<ChefConfig::WorkstationConfigLoader:0x0000000006f176a0>
Did you mean? credentials_profile
credentials_found
#credentials_found
----------------------
Please see .kitchen/logs/kitchen.log for more details
Also try running kitchen diagnose --all for configuration
We found that the problem in this case was an invalid profile being requested.
The profile can be set either with the CHEF_PROFILE environment variable, or in a file named 'context' in the users home .chef directory (~/.chef on Linux, C:\Users\username.chef on Windows).
If a profile other than 'default' is specified, than the ChefDK looks for a file named 'credentials' in that same directory. It will then parse that file and look for a section matching the profile name.
If it doesn't find a matching profile, then it will generate errors like the one in the question.
To fix the problem for this user, we changed the value of the 'context' file to "default" (without quotes) and everything started working again.
There are several possible resolutions, which one is best for you depends on where the problem comes from
If the profile name is valid, then add the proper section to the ~/credentials file
If the value of the CHEF_PROFILE environment variable is the problem, change it to "default" or to a valid name
If the value of the ~/context file is the problem, than you can either delete it, or change the value in it to a valid profile (NOTE: Always make a back up of the file before deleting or making changes)
I found the details listed above that led me to the resolution by going through the code in C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-config-15.1.36/lib/chef-config/mixin/credentials.rb (which was where the initial exception was thrown)

Error Installing XML component

I have just updated my IS2009 ISM to IS2012Spring premier edition. Installer is giving error while deploying. It is perfectly working fine with IS2009 installer. XML code
Please see below logs.
MSI (s) (78:20) [14:58:09:408]: Executing op:
ActionStart(Name=ISXmlInstall,,) Action 14:58:09: ISXmlInstall. MSI
(s) (78:20) [14:58:09:409]: Executing op:
CustomActionSchedule(Action=ISXmlInstall,ActionType=3073,Source=BinaryData,Target=ISXmlInstall,CustomActionData=C:\Users\WIN764\AppData\Local\Temp\XML6FE4.tmp)
MSI (s) (78:1C) [14:58:09:410]: Invoking remote custom action. DLL:
C:\Windows\Installer\MSI988C.tmp, Entrypoint: ISXmlInstall
InstallShield 14:58:09: Installing 1 XML component(s) InstallShield
14:58:09: Installing XML Component 'SebringAppConfig.xml'
InstallShield 14:58:09: Installing XML file 'C:\Program Files
(x86)\Pitney Bowes\SureTrac\Client\Data\SebringAppConfig.xml'
InstallShield 14:58:09: Using MSXML version 6 InstallShield 14:58:09:
Processing XPath '//' InstallShield 14:58:09: No namespace for prefix
pi found InstallShield 14:58:09: Node name: 'pi:APPLICATION' -->
Attribute name = 'pi:AppPath', Current Value = '', Operation = '1'
InstallShield 14:58:09: Node name: 'pi:APPLICATION' - Attribute name
= 'pi:AppPath', Old Value = '', New value = 'C:\Program Files (x86)\Pitney Bowes\SureTrac\Client\', Actual New Value = 'C:\Program
Files (x86)\Pitney Bowes\SureTrac\Client\' CustomAction ISXmlInstall
returned actual error code 1603 (note this may not be 100% accurate if
translation happened inside sandbox) Action ended 14:58:09:
InstallExecute. Return value 3.
I have config file added in component AppConfigFiles also a separate component as SebringAppConfig.xml.
Please see attached image.
Ok I have figured it out. Needed to add PI in namespace

ClickOnce fails on download

OK, I have a similar problem as Download ClickOnce fails from setup.exe and Download ClickOnce fails from setup.exe , where I have deployed a ClickOnce installer for a desktop app I am selling.
Different than those examples, I am using Visual Studio 2012 (Pro Version). Using .Net 3.5. I am deploying on a hosted LINUX machine. It worked for me and other people running Windows 7 & 8, possibly earlier versions of Widnows. Then after running a few tests in Debug mode, I built and deployed in Release mode. Now, the auto-installer breaks when it gets to the spot where it wants to download the .application file. Here's the log file.
The following properties have been set:
Property: [AdminUser] = true {boolean}
Property: [InstallMode] = HomeSite {string}
Property: [NTProductType] = 1 {int}
Property: [ProcessorArchitecture] = AMD64 {string}
Property: [VersionNT] = 6.2.0 {version}
Running checks for package 'Microsoft Visual Basic PowerPacks 10.0', phase BuildList
Attempting to find 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=YADDAYADDA' in the Global Assembly Cache
AssemblyCheck: Error querying assembly info: -2147024894
Attempting to find 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=YADDAYADDA, processorArchitecture=msil' in the Global Assembly Cache
Assembly found at 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualBasic.PowerPacks.Vs\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.PowerPacks.Vs.dll'
Setting value '11.0.50727.1 {version}' for property 'VBPowerPacksInstalled'
The following properties have been set for package 'Microsoft Visual Basic PowerPacks 10.0':
Property: [VBPowerPacksInstalled] = 11.0.50727.1 {version}
Running checks for command 'VBPowerPacks\VisualBasicPowerPacksSetup.exe'
Result of running operator 'ValueExists' on property 'VBPowerPacksInstalled': true
Result of checks for command 'VBPowerPacks\VisualBasicPowerPacksSetup.exe' is 'Bypass'
'Microsoft Visual Basic PowerPacks 10.0' RunCheck result: No Install Needed
Running checks for package '.NET Framework 3.5 SP1', phase BuildList
Reading value 'SP' of registry key 'HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5'
Read integer value 1
Setting value '1 {int}' for property 'DotNet35SP'
The following properties have been set for package '.NET Framework 3.5 SP1': Property: [DotNet35SP] = 1 {int}
Running checks for command 'DotNetFX35SP1\dotNetFx35setup.exe'
Result of running operator 'ValueGreaterThanEqualTo' on property 'DotNet35SP' and value '1': true
Result of checks for command 'DotNetFX35SP1\dotNetFx35setup.exe' is 'Bypass'
'.NET Framework 3.5 SP1' RunCheck result: No Install Needed
Launching Application.
URLDownloadToCacheFile failed with HRESULT '-2146697205'
Error: An error occurred trying to download 'http://www.mywebsite.com/ProductName/Downloads/oneclick/ProductName.application'.
I've looked at https://msdn.microsoft.com/en-us/library/ms229001.aspx , after which I set the MIME type of .application to x-ms-application. No difference.
When I put the url http://www.mywebsite.com/ProductName/Downloads/oneclick/ProductName.application into my browser, I get the text of the file, rather than a download.
Any thoughts??? Thanks!
OK, the first thing that got me closer to the solution was simply to reboot the PC I was dwonloading onto. This got me further into the install, but I then ran into another problem, the solution to which I found at ClickOnce application replace current installed fliles . Clearing out the folder C:\Users\Charles\AppData\Local\Apps\2.0got me to where I could install and run the app fully.
Window application in C #. My solution, I hope it serves someone. The domain server was damaged, I just changed the IP of the new DNS server. It was not necessary to join that new domain server IP.
The "An error occurred trying to download.." error occurs with one of our click-once apps and the solution is to turn off IE Enhanced Security from Server Manager (Server 2012R2+) on the target machine.

Cruisecontrol.net with UCM Clearcase - How to?

I am trying to configure Cruisecontrol.net for UCM Clearcase for the first time. Following is the sourceControl tag in the ccnet.config file:
<sourcecontrol type="clearCase">
<branch>123_India_Release</branch>
<autoGetSource>true</autoGetSource>
<viewName>admin_123_CRUISE</viewName>
<viewPath>$(ViewDirectory)</viewPath>
<useLabel>false</useLabel>
<useBaseline>false</useBaseline>
<executable>cleartool.exe</executable>
</sourcecontrol>
I constantly receive the following error:
ThoughtWorks.CruiseControl.Core.CruiseControlException: Source control
operation failed: cleartool: Error: Not an object in a vob: "PATH TO
THE VIEW"
When I run cleartool from an arbitrary directory with the following parameters:
cleartool.exe lshist -r -nco -branch "123_India_Release" -since
05-Dec-2012.14:38:18 -fmt
I get the same error. But if I change the working directory to $(ViewDirectory) before running cleartool, it runs fine.
How should I make Cruisecontrol.net run cleartool.exe from the $(ViewDirectory)?
I have already tried adding <workingDirectory>$(ViewDirectory)</workingDirectory> tag before <executable>cleartool.exe</executable> but it did not work.
Any help would be appreciated.
EDIT 1:
As a workaround I have done the following:
<exec>
<executable>cleartool.exe</executable>
<baseDirectory>d:\Workspace\123_India_Release\VOB</baseDirectory>
<buildArgs>update -force</buildArgs>
<buildTimeoutSeconds>6000</buildTimeoutSeconds>
</exec>
I have added this to the tasks tag. I have configured an hourly trigger which does the following:
1) Update snapshot view
2) Build the VS 2010 solutions mentioned in the tasks tag.
The limitations are:
1) The trigger is hourly. I want it to be a commit based trigger.
2) This is a workaround
EDIT 2:
Further experimentation revealed that the ccnet.exe works fine. It does all that is needed. The issue is caused by the service ccservice.
I have stopped ccservice for now and started ccnet.exe. I plan to leave it running.
The View directory isn't enough: you must specify a vob.
See for instance:
"clearfsimport: Error: Not an object in a vob: "\"." (as an illustratio of that error message)
this thread (or this one): "You have to specify explicitly the VOB(s) to check for modification set"
The path should looks like:
<viewPath>Drive:\path\to\view\vobname</viewPath>
If your $(ViewDirectory) already references Drive:\path\to\view, then you could use:
<viewPath>$(ViewDirectory)\vobname</viewPath>

How do you get the path of the running script in groovy?

I'm writing a groovy script that I want to be controlled via a properties file stored in the same folder. However, I want to be able to call this script from anywhere. When I run the script it always looks for the properties file based on where it is run from, not where the script is.
How can I access the path of the script file from within the script?
You are correct that new File(".").getCanonicalPath() does not work. That returns the working directory.
To get the script directory
scriptDir = new File(getClass().protectionDomain.codeSource.location.path).parent
To get the script file path
scriptFile = getClass().protectionDomain.codeSource.location.path
As of Groovy 2.3.0 the #SourceURI annotation can be used to populate a variable with the URI of the script's location. This URI can then be used to get the path to the script:
import groovy.transform.SourceURI
import java.nio.file.Path
import java.nio.file.Paths
#SourceURI
URI sourceUri
Path scriptLocation = Paths.get(sourceUri)
Note that this will only work if the URI is a file: URI (or another URI scheme type with an installed FileSystemProvider), otherwise a FileSystemNotFoundException will be thrown by the Paths.get(URI) call. In particular, certain Groovy runtimes such as groovyshell and nextflow return a data: URI, which will not typically match an installed FileSystemProvider.
This makes sense if you are running the Groovy code as a script, otherwise the whole idea gets a little confusing, IMO. The workaround is here: https://issues.apache.org/jira/browse/GROOVY-1642
Basically this involves changing startGroovy.sh to pass in the location of the Groovy script as an environment variable.
As long as this information is not provided directly by Groovy, it's possible to modify the groovy.(sh|bat) starter script to make this property available as system property:
For unix boxes just change $GROOVY_HOME/bin/groovy (the sh script) to do
export JAVA_OPTS="$JAVA_OPTS -Dscript.name=$0"
before calling startGroovy
For Windows:
In startGroovy.bat add the following 2 lines right after the line with
the :init label (just before the parameter slurping starts):
#rem get name of script to launch with full path
set GROOVY_SCRIPT_NAME=%~f1
A bit further down in the batch file after the line that says "set
JAVA_OPTS=%JAVA_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%" add the
line
set JAVA_OPTS=%JAVA_OPTS% -Dscript.name="%GROOVY_SCRIPT_NAME%"
For gradle user
I have same issue when I'm starting to work with gradle. I want to compile my thrift by remote thrift compiler (custom by my company).
Below is how I solved my issue:
task compileThrift {
doLast {
def projectLocation = projectDir.getAbsolutePath(); // HERE is what you've been looking for.
ssh.run {
session(remotes.compilerServer) {
// Delete existing thrift file.
cleanGeneratedFiles()
new File("$projectLocation/thrift/").eachFile() { f ->
def fileName=f.getName()
if(f.absolutePath.endsWith(".thrift")){
put from: f, into: "$compilerLocation/$fileName"
}
}
execute "mkdir -p $compilerLocation/gen-java"
def compileResult = execute "bash $compilerLocation/genjar $serviceName", logging: 'stdout', pty: true
assert compileResult.contains('SUCCESSFUL')
get from: "$compilerLocation/$serviceName" + '.jar', into: "$projectLocation/libs/"
}
}
}
}
One more solution. It works perfect even you run the script using GrovyConsole
File getScriptFile(){
new File(this.class.classLoader.getResourceLoader().loadGroovySource(this.class.name).toURI())
}
println getScriptFile()
workaround: for us it was running in an ANT environment and storing some location parent (knowing the subpath) in the Java environment properties (System.setProperty( "dirAncestor", "/foo" )) we could access the dir ancestor via Groovy's properties.get('dirAncestor').
maybe this will help for some scenarios mentioned here.

Resources