Help using signtool.exe in Delphi project post-build events - delphi

This is a very simple question. What should I write in Delphi post build events to execute a coomand line tool?
I wrote this:
c:\BinPath\signtool.exe sign /f c:\BinPath\Mypfxfile.pfx /p MyPassword
/t http:// timestamp.verisign.com/scripts/timstamp.dll c:\BinPath\Project1.exe
(where c:\BinPath is the Delphi output path, for simplicity I copied signtool.exe adn pfx file in the same folder)
as i build the project I have this modal window error:
--------------------------- Project 1- CodeGear Delphi for Microsoft Windows - Form1
--------------------------- Cannot open file "C:\SourcePath\EXEC".
Impossible to find the specified
path..
and in the messages I have
[Exec Error] EXEC(1):
"SignerTimeStamp() failed."
(-2147467259/0x80004005)
[Exec Error]
exit from command
"c:\BinPath\signtool.exe sign /f
c:\BinPath\Mypfxfile.pfx /p MyPassword
/t http://
timestamp.verisign.com/scripts/timstamp.dll
c:\BinPath\Project1.exee" with code 1.
How to manage this? In Delphi help I read (from Creating Build Events topic):
Enter the build commands, one command per line, and press Return after entering each command. Commands consist of any valid DOS command, such as: copy $() c:\Built\$()
So i simply inserted in the build event what (c:\BinPath\....Project1.exe) I was able to run from command prompt. Where is the error? Thanks.

I could have deleted this question, since I found the problem, but I think it is better to leave it since it can be useful for others:
THE PROBLEM WAS SIMPLY
http:// timestamp...
of course should be
http://timestamp...
when copying on build event I inserted an extra space by mistake. By reading the question posted I found the error...

Related

TFS2015 Build fails on all Command Line Commands with 'file not found'

In Team Foundation Server 2015 Build (on-premise), I'm having issues running simple command line commands. All Command Line tasks simply fail with the following error: "File not found: ".
Take for example the following build definition:
This is executed using an on-premise Build Agent and will fail with the following exception in the logs:
BUILD FAILED
2016-01-20T12:04:47.5127709Z ##[warning]Filename doesn't indicate a full path to a executable file.
2016-01-20T12:04:47.5127709Z Executing the following commandline. (workingFolder = D:\_work\2\s)
2016-01-20T12:04:47.5127709Z date
2016-01-20T12:04:47.5127709Z Error message highlight pattern:
2016-01-20T12:04:47.5127709Z Warning message highlight pattern:
2016-01-20T12:04:47.5439748Z ##[error]File not found: date
Of course this is a simplified example where I simply want to output the current date using the date /t command. But the same problem occurs with all general command line commands which I've tried, such as dir, time, path etc. The MSDN does not provide any troubleshooting info on it, other than that the tool executed must reside in the PATH variable.
The issue is not specific to one build definition or repo; it can be reproduced on others as well.
The builds run as the built-in svc_tfsbuild account.
I'm perhaps thinking this is either a simple setting, or - wildly guessing - an issue related to rights, but cannot find any documentation where to look or what to check. Any help would be appreciated.
It appears this is a known issue on MS Connect as well.
In short a MSFT mentions the following:
Commands that are built-in to command prompt don't work. Anything resolvable based on your PATH/PATHEXT will work.
In the comment from 27 Oct, 2015 it is stated that this will be fixed in the next sprint. The mentioned workaround for now is simply executing cmd.exe first and provide the rest as arguments.
Using the example from the original question this would lead to:
Tool: cmd.exe
Arguments: /c "date /t"
And I can indeed confirm this works.

Check if driver is unsigned before attempting to install

From a scripting view, can you check if a driver is unsigned - or more accurately check if the publisher cannot be verified - before you attempt to install?
Problem similar to this:
How to get rid of "windows can't verify the publisher of this driver software" window?
I don't WANT to install the driver if the "Windows can't verify the publisher of this driver software" message appears; I simply want to check.
I am happy with any scripted or coded solution.
Signtool.exe can be used to check signature.
Please read MSDN link about signtool.exe options. Signtool can be find out at %program files%/windows Kits\8.1\bin
To test a signature for the purpose of running an executable or installing a driver package, the correct option is /pa. Please refer KMCS_Walkthrough.doc.
To test a signature for the purpose of loading kernel-mode code, the correct option is /kp.
Example of Batch file that verifies the signature of a file, using /pa:
"C:\Program Files (x86)\Windows Kits\8.0\bin\x86\signtool" verify /v /pa %1
pause
some more examples:
Signtool verify /pa /v /c tstamd64.cat amd64\toaster.sys
Please refer MSDN entry and Blog entry for more detailed information about driving signing.

Installing a driver in NSIS script

I'm trying to create an NSIS installer that installs an inf file. The inf file is extracted from the installer to the correct place, and then I use:
nsExec::ExecToLog '"$SYSDIR\PnPutil.exe" /a "$INSTDIR\driver\xser.inf"'
However, the command does not seem to get executed at all - the install log doesn't print anything - not success nor failure. I've checked thoroughly the command line and it points to the right PnPutil path. I've also checked that it's being run with administrator privileges and it also looks correct. Replacing PnPutil.exe with a different executable in the System32 directory also seem to work without any problem. What am I missing here?
If this only happens on 64bit systems you can try to disable FS redirection around the call to nsExec::ExecToLog by using the macros in x64.nsh:
!include x64.nsh
${DisableX64FSRedirection}
nsExec::ExecToLog '"$SYSDIR\PnPutil.exe" /a "$INSTDIR\driver\xser.inf"'
${EnableX64FSRedirection}

DCC32 compiler configuration file and command line parameter precedence

I am trying to build first time my Delphi application through command line using DCC32. I have few doubts regarding the configuration file of my project. There are some search paths I have to add to project when compiling through IDE. When I remove them, the compilation fails.
Now if I compile it through command line is it need to specify configuration file details or the search path parameters?
without any parameters:
dcc32.exe project1.dpr
with some parameters:
dcc32.exe -u%Shared% -ND:\out project1.dpr
I have following doubts:
if the config file details are not mentioned then it will take settings automtically from project.cfg (created by IDE)??
if yes then if i mentioned the -U,-N options in command line then it will override All the settings which are in .cfg ile?
This question sounds foolish but want to know What is use of compiling through command line over IDE?
Please provide some help to resolve my doubts. Any information related to dcc32 compilation options will be appreciated.
1. - If the project config file is not specified in the command line options, will the settings be taken from the project's cfg file generated by IDE ?
Yes.
2. - When I use the -U, -N options in command line will that override all the settings from a project cfg file ?
No. Command line options takes precedence though, but only those options you specify will override the settings from the project's *.cfg file, not the whole configuration
3. Is there a difference between compilation from command line and compilation from IDE ?
No. There is no difference speaking about Delphi 5. From my view, the command line way just brings you the possibility to automate a build process through command line batch without need of opening IDE.
It's been a while, but I believe you are correct in your assumptions about the command-line vs the .cfg file. You can verify this yourself by having one path in the .cfg and specifying a different one on the command line and, say, have an error in the file that the .cfg would reference and see if the compiler hits the error.
Compiling from the command-line is convenient for automated build systems but is otherwise the same as compiling through the IDE.

Delphi 2009 command line compiler using dcc32.cfg?

In Delphi 2009, how can I build a project using command line. I tried using the command line compiler and supplying -a -u -i -r in dcc32.cfg file. But compiler is not recognizing the paths and throwing the error required package xyzPack is not found.
-aWinTypes=Windows;WinProcs=Windows;DbiProcs=BDE;DbiTypes=BDE;DbiErrs=BDE
-u"C:\MyProj\Output\DCP"
-i"C:\MyProj\Output\DCP"
-r"C:\MyProj\Output\DCP"
and on command line i execute the command :
dcc32 "C:\MyProj\MyProject.dpr" -B -E"c:\MyProj\Output\EXE"
What am I doing wrong here?
Thanks & Regards,
Pavan.
Instead of invoking the compiler directly, consider using MSBuild on your .dproj, since that's what the IDE uses. Delphi MSBuild Build Configurations From Command Line might help you with that.
From the related answer (as shown below) ie:
Compiling with Delphi 2009 from a command line under Windows Vista 64-bit
I notice that you should be able to build a single package from the command line this way. I have used batch files (buildall.cmd) to launch dcc32, and have not yet used msbuild.
I have ultimately found both approaches frustrating, and have instead decided to opt for building a little GUI shell (a lite version of Final Builder, if you like) that basically works as a semi-graphical semi-command-line way of automating my builds and filtering the compiler output to produce results. I would be highly interested in anyone else's experiences with "tinder box" (daily or even continuous build) operations with Delphi.
You may end up where I'm heading... just buy Final Builder. :-)

Resources