CruiseControl.NET and Mounting a Drive - cruisecontrol.net

I am running CruiseControl.NET as a service but some of the projects that I am building reference things using a network drive. As In H:... instead of \machine\dir. I can't change the project references. How can I mount the H: drive before the project builds or maybe when CruiseControl starts running?

From a command line, you can call "net use" to set up a mapped drive. You might be able to run this from an exec task before the code is compiled.

I've tested the following .bat file and it worked fine using:
- CruiseControl.Net version 1.5.7256.1
- a .bat file running from an <exec> task.
.bat file
ECHO OFF
NET USE \\Server\data /USER:domain\user password
ECHO ON
C:\utils\robocopy.exe C:\build\data \\Server\data *.*
ccnet.config
<project name="ProjectName">
<!-- snip -->
<tasks>
<!-- snip -->
<exec>
<executable>deploy.bat</executable>
<baseDirectory>Configuration\</baseDirectory>
<buildArgs></buildArgs>
<buildTimeoutSeconds>60</buildTimeoutSeconds>
<successExitCodes>0,1,2,3,4,5,6,7,8</successExitCodes>
</exec>
Notes:
I installed the Cruise Control service using default settings and accounts.
I turn echo off and then on, to prevent user details from being put into build logs.
I got the hint to not use drive letters from this:
Mapping a network drive without hardcoding a drive letter in a batch file
Update: Included ccnet.config syntax

in my ccnet.config:
<exec>
<executable>setup_build.cmd</executable>
<baseDirectory>&BaseDIR;\CruiseControlNET</baseDirectory>
<buildArgs>&BaseDIR;\AllProjectsTFS</buildArgs>
<buildTimeoutSeconds>&BuildTimeoutInSeconds;</buildTimeoutSeconds>
</exec>
And I checked setup_build.cmd under my CruiseControlNet directory in SVN (setup as described in: http://confluence.public.thoughtworks.org/display/CCNET/Configure+CruiseControl.Net+to+Automatically+Update+its+Config+File)
setup_build.cmd contains:
#ECHO OFF
:CHECK_PARAMETERS
IF "%1"=="" GOTO SYNTAX
:PRINT_PARAMETERS
SET BASE_DIRECTORY=%1
ECHO PARAMETERS:
ECHO BaseDirectory: %BASE_DIRECTORY%
ECHO.
:ARTIFACTS_DIRECTORY
ECHO CREATING ARTIFACTS DIRECTORY:
SET ARTIFACTS_DIR=%BASE_DIRECTORY%\Artifacts
ECHO Creating Artifacts Directory in: %ARTIFACTS_DIR%
IF EXIST %ARTIFACTS_DIR% RMDIR /S /Q %ARTIFACTS_DIR%
MKDIR %ARTIFACTS_DIR%
ECHO SUCCESS
ECHO.
:SETUP_NETWORK_DRIVES
ECHO MAPPING NETWORK DRIVES:
IF NOT EXIST H: NET USE H: \\server\share
NET USE
GOTO END
:SYNTAX
ECHO Wrong Arguments:
ECHO SYNTAX: setup_build.cmd [BASE_DIRECTORY]
EXIT /B -1
:END
EXIT /B 0

Related

Signing with full path with spaces to signtool.exe fails with “Sign Tool failed with exit code 0x1” in Inno Script Studio

In Inno Setup, my sign tool is defined as:
cmd /k "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe" sign /t http://timestamp.comodoca.com /n "My Company" $f
Prepending cmd /k (as suggested at Inno Setup - Signing fails with "Sign Tool failed with exit code 0x1") reveals that there is not actually a problem with the sign tool itself, but rather how Inno Setup is calling it, generating the following message:
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
Clearly, it's chopping off the path to signtool at the first space, even though I put it in quotes. I even tried replacing the quotes with $q to see if that made any difference. (It didn't.) I would think this is improper behavior for the parser to dishonor the quotes, since the instructions clearly say to paste the exact text you'd use on the command line, and the example itself includes quotation marks (https://revolution.screenstepslive.com/s/revolution/m/10695/l/563371-signing-installers-you-create-with-inno-setup).
Everything works beautifully from the command line. For some reason, Inno Setup just isn't properly calling signtool.
ADDED 2020-07-14:
Inno Setup's example, copied from their website:
"C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin\signtool.exe" sign /f "C:\MY_CODE_SIGNING.PFX" /t http://timestamp.comodoca.com/authenticode /p MY_PASSWORD $f
My version, used without the cmd /k:
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe" sign /t http://timestamp.comodoca.com /n "My Company" $f
As you can see, we use quotes in the same manner. I will check for updates - I probably should have done that first. When I get some time, I'll revert the signtool definition and see if maybe the update fixes it.
Also, I should have been more clear. I am new to Inno Setup and it didn't occur to me to clarify this. I am compiling via Inno Script Studio. It occurs to me that there's some possibility this has to do with a behavior in a specific version of Script Studio and not the compiler itself, but I don't know enough about the inner workings to do any more than speculate.
Having done a bit more tinkering, I'm now fairly certain this must be a bug with Inno Setup. I implemented a work-around as follows:
Open a command window with elevated privileges
Change to a directory I created with no space in the name: cd \bin
Create a 'spaceless' symbolic link to the directory where signtool.exe is located: mklink /d "Windows10SDK" "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64"
Enter new sign tool definition that uses the symbolic link:
C:\bin\Windows10SDK\signtool.exe sign /t http://timestamp.comodoca.com /n "My Company" $f
And that's it! Because there is no longer a space character in the path to signtool.exe, Inno Setup now performs the signing correctly and everything works beautifully.
I'll report this as a bug and update if needed.
I use:
#define SignedDesc "$q" + MSA + "$q"
#define SignedPfx "$qd:\My Certificate\2018\My Certificate.pfx$q"
#define SignedTimeStamp "$qhttp://timestamp.verisign.com/scripts/timestamp.dll$q"
#define SignedPw "$q~~~~~~~$q"
SignTool=SignTool /d {#SignedDesc} /du $q{#AppURL}$q /f {#SignedPfx} /p {#SignedPw} /t {#SignedTimeStamp} /v $f
My sign tool is configured as:
$qC:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x86\Signtool.exe$q sign $p
You have to use $q which is a quote mark.

Making help file errors in Visual C++ 6.0 Standard Edition

I am trying to compile and build my test program. however, I am getting the following error.
Making help file...
'".\makehelp.bat"' is not recognized as an internal or external command,
operable program or batch file.
Error executing c:\windows\system32\cmd.exe.
hpled6_2565.exe - 1 error(s), 0 warning(s)
Do you know how I can solve it? I am using Visual C++ 6.0 Standard Edition.
'".\makehelp.bat"' is not recognized as an internal or external command,
operable program or batch file.
Error executing c:\windows\system32\cmd.exe.
The above seems to indicate that your test program is missing the makehelp.bat file.
That in itself is easy to fix, just replace XYZ with your project name in the template auto-generated by VC6 (copied below) and save it as makehelp.bat in the project directory.
#echo off
REM -- First make map file from Microsoft Visual C++ generated resource.h
echo // MAKEHELP.BAT generated Help Map file. Used by XYZ.HPJ. >"hlp\XYZ.hm"
echo. >>"hlp\XYZ.hm"
echo // Commands (ID_* and IDM_*) >>"hlp\XYZ.hm"
makehm ID_,HID_,0x10000 IDM_,HIDM_,0x10000 resource.h >>"hlp\XYZ.hm"
echo. >>"hlp\XYZ.hm"
echo // Prompts (IDP_*) >>"hlp\XYZ.hm"
makehm IDP_,HIDP_,0x30000 resource.h >>"hlp\XYZ.hm"
echo. >>"hlp\XYZ.hm"
echo // Resources (IDR_*) >>"hlp\XYZ.hm"
makehm IDR_,HIDR_,0x20000 resource.h >>"hlp\XYZ.hm"
echo. >>"hlp\XYZ.hm"
echo // Dialogs (IDD_*) >>"hlp\XYZ.hm"
makehm IDD_,HIDD_,0x20000 resource.h >>"hlp\XYZ.hm"
echo. >>"hlp\XYZ.hm"
echo // Frame Controls (IDW_*) >>"hlp\XYZ.hm"
makehm IDW_,HIDW_,0x50000 resource.h >>"hlp\XYZ.hm"
REM -- Make help for Project XYZ
echo Building Win32 Help files
start /wait hcw /C /E /M "hlp\XYZ.hpj"
if errorlevel 1 goto :Error
if not exist "hlp\XYZ.hlp" goto :Error
if not exist "hlp\XYZ.cnt" goto :Error
echo.
if exist Debug\nul copy "hlp\XYZ.hlp" Debug
if exist Debug\nul copy "hlp\XYZ.cnt" Debug
if exist Release\nul copy "hlp\XYZ.hlp" Release
if exist Release\nul copy "hlp\XYZ.cnt" Release
echo.
goto :done
:Error
echo hlp\XYZ.hpj(1) : error: Problem encountered creating help file
:done
echo.
However, for this to work, you also need a resource.h following the VC6 resource IDs conventions, plus the respective .hpj and .cnt files.
Also, you should be aware that even if you get it to work, the end result will be a HLP file that's been deprecated since Vista, and requires a separate WinHlp32 install to be viewable at all (https://support.microsoft.com/en-us/kb/917607).

Batch file fails when solution is built by Jenkis, but works when solution is built via command line

The problem
I have a batch file the is being called from a Pre-Build event.
When the solution is being built by Jenkins it fails.
When the solution is being built from MSBuild or visual studio in command line It works fine.
My question is, what could cause such a behaviour?
Details
In my solution (.Net 4.5 and C++ projects), I have a batch file that is called from one of the project's Pre-Build events.
It works fine, except when I am trying to build the solution via Jenkins (CI Server).
The error is :
The command ""C:\Jenkins\apps\jenkins\jenkins_home\jobs\Builld_SMW2\workspace\Autosync\CopySymAlignFiles.bat" "C:\Jenkins\apps\jenkins\jenkins_home\jobs\Builld_SMW2\workspace\" "C:\Jenkins\apps\jenkins\jenkins_home\jobs\Builld_SMW2\workspace\Autosync\" "Debug"" exited with code 1.
from the error report, I copied the command that was used for attempting to build the solution:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Platform=x86 /p:configuration=Debug /t:Rebuild /verbosity:quiet /p:WarningLevel=0 /p:Platform=x86 /p:configuration=Debug /t:Rebuild /verbosity:quiet /p:WarningLevel=0 ..\SMW2_Analysis.sln
(I am aware that the arguments are being passed twice, I have no Idea why jenkins does that, but this is not the issue...)
If I run this command from command line, the batch file works fine once the build event is triggered.
The content of CopySymAlignFiles.bat is:
Echo off
set solutionDir=%1
set projectDir=%2
set configuration=%3
REM Removing quotes
set solutionDir=%solutionDir:"=%
set projectDir=%projectDir:"=%
set configuration=%configuration:"=%
REM Does strings have a trailing slash? if so remove it
IF %solutionDir:~-1%==\ SET solutionDir=%solutionDir:~0,-1%
IF %projectDir:~-1%==\ SET projectDir=%projectDir:~0,-1%
IF %configuration:~-1%==\ SET configuration=%configuration:~0,-1%
REM This is just for easier debugging
Echo Solution Directory is: "%solutionDir%"
Echo Project Directory is: "%projectDir%"
Echo Configuration directory is: "%configuration%"
Echo Current Directory is: "%CD%"
Echo The batch file is executed at "%~dp0"
REM Copying sym_align files
copy /Y "%solutionDir%\SymAlignGlue\sym_align.dll" "%projectDir%"
copy /Y "%solutionDir%\SymAlignGlue\sym_align.ctf" "%projectDir%"
set isPV=%configuration%=="PV Release"
IF %isPV% copy /Y "%solutionDir%\SymAlignGlue\Release\SymAlignGlue.dll" "%projectDir%"
IF NOT %isPV% copy /Y "%solutionDir%\SymAlignGlue\%configuration%\SymAlignGlue.dll" "%projectDir%"
REM The result...
IF %ERRORLEVEL% EQU 0 (
REM Success
Echo Copied SymAlign files.
exit /b 0
)
IF NOT %ERRORLEVEL% EQU 0 (
REM Error
Echo An error was found while Copied SymAlign files. Error level was %ERRORLEVEL%
exit /b %ERRORLEVEL%
)
Some additional Information:
I am running Jenkins as a service and I have the service logon as An Administrator.
Does Anyone have an Idea how can this happen?
At the end, it seems that the issue was that there was a duplicate workspace folder.
1 was updated, and the other 1 was built, resulting the tested workspace did not get latest updates.
according to this link this was due to the way jenkins behaves with multiple configurations.

Trying to Setup Android Project using .bat to replace text in .xml files

I am trying to setup android projects. This is a quick and easy way to do it, so all I have to do is import the final code into eclipse and export it. I use a base source code for all my projects and all I have to do is just change the app title and package name and new drawables and I have another app, However my .bat script looks like this.
#echo off
rmdir /s /q "%~dp0out"
mkdir out
xcopy "%~dp0other\backup" "%~dp0out" /E > nul
java -version
if errorlevel 1 goto errjava
cls
echo.
PAUSE
echo.
echo packagae name
echo whats your packagename after cube3d.packagename
echo.
set /P INPUT=Enter: %=%
echo.
echo App Name
echo whats your App name before Live Wallpaper
echo.
set /P INPUT2=Enter: %=%
echo.
echo Airpush App ID
echo What is the 6 digit airpush app id
echo.
set /P INPUT3=Enter: %=%
copy "%~dp0placeimages" "%~dp0out\res\drawable"
rename out\src\cube3d\aaaaapnzme %INPUT%
call run2.bat
call run3.bat
call run4.bat
It will run and go to run2.bat and stop after. it doesn't do run3.bat afterwards it fails to go to the 3rd and then the 4th. This is what the other bats look like.
run2.bat looks like this and this one works perfectly.
rep "aaaaapnzme" "%INPUT%" out\src\cube3d\%INPUT%\*.java out\AndroidManifest.xml out\src\cube3d\%INPUT%\objects\*.java
that's as far as the script will go and it fails to go to run3.bat and then to run4.bat
run3.bat looks like this
rep "zapsname" "%INPUT2%" out\res\values\strings.xml
run4.bat looks like this
rep "aeropush" "%INPUT3%" out\AndroidManifest.xml
I am using Windows 8 Pro if that helps any.
What is rep ?
perhaps CALL rep... would fix the problem.

How to add files/folders to multiple zip files at once with WinRAR?

Is there any way to add files/folders to multiple zip files at once. For example:
Updates:
folder1
folder2
file1
file2
Archives:
archive1.zip
archive2.zip
archive3.zip
I need to add updates to all archives without opening all of them and pasting updates in there.
Any way to do this?
Or is there another archive program that can do this?
This can be done using a batch file and for example WinRAR.
#echo off
if not exist archive*.zip (
echo There are no archive*.zip files to update in
echo.
echo %CD%
echo.
pause
goto :EOF
)
set "ErrorCount=0"
for %%I in (archive*.zip) do (
"%ProgramFiles%\WinRAR\WinRar.exe" u -afzip -cfg- -ep1 -ibck -inul -r -y "%%I" folder1 folder2 file1 file2
if errorlevel 1 (
echo Error on updating %%I
set /A ErrorCount+=1
)
)
if not "%ErrorCount%" == "0" (
echo.
pause
)
set "ErrorCount="
For each archive*.zip file WinRAR is called to update the ZIP file with the two folders and the two files.
The batch processing finishes without printing any message and without pausing if all ZIP files found could be updated successfully. Otherwise the batch file outputs which ZIP file could not be updated for example because of read-only attribute set, and pauses the batch processing before finishing so that the user can read the error message(s).
For details on the WinRAR command u and the used switches open in WinRAR from menu Help the Help topics, open on tab Contents the item Command line mode and read at least the help pages:
Command line syntax
Commands - Alphabetic commands list
Switches - Alphabetic switches list
For understanding the other used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
echo /?
for /?
goto /?
if /?
pause /?
set /?
You can do it by using 7zip command line version
7z a archive1.zip dir\ -v10k -v15k -v2m #listfile.txt
this will do archive all files and folder is in that folder named 'dir'
and first volume will be 10kb, second will be 15kb and others will be 2mb each except last
and you can use a file that has list of all files named.

Resources