NANT Build error : Cmd - build

I am trying to execute a NAnt build script, which is perfectly working in one environment, but recently I have migrated my Build files to a new machine where I am facing the below issue.
NAnt Code Used :
exec program="cmd" commandline="/c ${build.dir}\XXX.vbs ${build.version}" failonerror="false"
NAne Error received
External Program Failed: cmd (return code was 1)
My Possible tries to overcome this
I have checked the environment variables and found that all are fine and also compared with the old machine to match the same.
Any solutions / comments ??

It seems "cmd" is running and you don't need to provide the full path. The error "External Program Failed: cmd (return code was 1)" means the 'cmd' ran but it produced an error. In other words your VB script (i.e. 'XXX.vbs') is failing. Try the following to find the actual error:
Validate that the expanded value of "${build.dir}\XXX.vbs" is a valid file/location. Double check your working directory if you're working with relative paths.
<echo message="${build.dir}\XXX.vbs" />
or
<echo message="${file::exists(build.dir + '\XXX.vbs')}" />
Run your NAnt script from the command line. This will give you a better error message, like a popup error from Windows Script Host.
C:\YourTools\NAnt.exe -buildfile:MyBuildScript.build
Avoid the command window, redirect the program's output. Append " >> exec.log" to your commandline string in the 'exec' task, then check the contents of the output/log file (i.e. 'exec.log').
<exec program="cmd" commandline="/c ${build.dir}\XXX.vbs ${build.version} >> xxx_exec.log" failonerror="false" />
Alternatively, a better way to use the 'exec' task is to use nested 'arg' elements. This would help in the case that your arguments have spaces in them; and your script will read clearer:
<exec program="cmd" failonerror="false">
<arg value="/c" />
<arg value="${build.dir}\XXX.vbs" />
<arg value="${build.version}" />
</exec>
Lastly, in the case your VB script is failing because of invalid arguments (maybe because of spaces in '${build.version}'), use something like the following to debug the VB script:
WScript.echo "Argument count", wscript.arguments.count
For i = 0 to wscript.arguments.count - 1
Wscript.Echo wscript.arguments.item(i)
Next
Hope this helps.

Related

After creating Pre-build event, get error "The Exec task was not given a value for the required parameter Command"

I added some prebuild script to a Visual Studio 2017 project.
powershell.exe -ExecutionPolicy ByPass -NoProfile -NonInteractive -File "./myscript.ps1"
It's just a script outputting some information in console.
The script executes correctly, whether it is launched directly in my Powershell console or from the build event (I can see the correct output in the Build Output panel in VS).
After the execution, the build fails with one error :
The "Exec" task was not given a value for the required parameter "Command"
I tried to reduce the problem to a minimal "./myscript.ps1" to show you my problem, and the problem occurs with any script, even an empty one!
And again, whatever the PS script is, it gives its output correctly.
Why does my build fail, and what can I do to fix it, while still running the script before build ?
The issue was caused by this entry in the .csproj project file :
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="" />
</Target>
Apparently, I (or VS ;) ) mistakenly added an empty script for PostBuild at the same time.
Removing the quoted entry solved the problem.
Thanks to Hans Passant's comment for pointing to the right direction.

Phing keeps building despite failures of CakePHP unit testing

we do deployment using Jenkins job and Phing for builds. Our app is made on CakePHP. When I run Cake unit tests I got some errors (as expected).
/app/Console/cake test app AllQaTests --stderr --log-junit
But Phing doesn't perceive them and keeps building instead of stopping the process and marking the build as failed. Is there any elegant way of handling output of tests?
Now we use a separate script which scans test log and seeks for "FAILURE" word.
If your cake command outputs anything other than 0, it would be considered FAILURE by Jenkins, and the job will be marked accordingly.
To answer your question for searching console log for keywords, there is Text-finder plugin that allows to search console log and/or any other file for a RegEx, and mark the build as UNSTABLE or FAILED if found.
I was about to do the same, but eventually tried to catch failed builds via Phing using returnProperty of ExecTask:
<target name="caketest-local" description="Run CakePHP unit tests with PHPUnit and print human readable output.">
<exec dir="${basedir}" executable="${basedir}/app/Console/cake" output="${logdir}/caketest.log" returnProperty="test_result">
<arg line="test" />
<arg line="--stderr"/>
<arg line="--configuration=${basedir}/phpunit-coverage-text.xml" />
<arg line="app" />
<arg line="AllTests" />
</exec>
<if>
<not>
<equals arg1="${test_result}" arg2="0"/>
</not>
<then>
<fail msg="Build FAILED! Check caketest.log for details"/>
</then>
</if>
</target>

Launch x86 or x64 MSI from MSBuild bootstrapper - newb

I don't have much of a programming background, but I have been using Wix to build very basic installations for several years, usually consisting of a browser shortcut with an icon file (The desktop shortcut simply opens 32-bit Internet Explorer to a specific URL). The clientele that use my installers don't usually know about their system and it appears the time has come where I can create a bootstrapper that will run 1 of the 2 .msi files, one for x86 & one for x64. The problem is that the Wix help documentation out there assumes a certain level of knowledge about programming and/or Wix and I need "for dummies" level of help. Using code snippets from Rob's answers to an earlier post here (similarly titled) and a post on another site, I have this in my .wxs:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Bundle Name="Intermountain SecureAccess Desktop Icon Installer" Version="1.0.0.0" Manufacturer="Intermountain Healthcare" UpgradeCode="61b75a8f-67f6-43a1-beb9-1a0be426b5a6">
<BootstrapperApplicationRef Id='WixStandardBootstrapperApplication.HyperlinkLicense' />
<Payload SourceFile="86IHCSAHCO.msi"/>
<Payload SourceFile="64IHCSAHCO.msi"/>
<Payload SourceFile="C:\Program Files (x86)\WiX Toolset v3.7\SDK\Microsoft.Deployment.WindowsInstaller.dll"/>
</BootstrapperApplicationRef>
<Chain>
<PackageGroupRef Id='Netfx4Full' />
<MsiPackage SourceFile="IHCSAHCO.msi" Id="InstallationPackageId" Cache="yes" Visible="no"/>
<MsiPackage InstallCondition='NOT VersionNT64' SourceFile='86IHCSAHCO.msi' />
<MsiPackage InstallCondition='VersionNT64' SourceFile='64IHCSAHCO.msi' />
</Chain>
</Bundle>
</Wix>
The goal is to create a single .msi (or .exe) called IHCSAHCO.msi which contains the 2 msi packages 86IHCSAHCO.msi & 64IHCSAHCO.msi and then simply runs one or the other depending on the environment. When I run the batch file (called Burn.wxs) with this in it...
set WIX_ROOT=%programfiles(x86)%\WiX Toolset v3.7\bin
del /q /f *.wixobj *.msi
call "%WIX_ROOT%\candle.exe" Burn.wxs
call "%WIX_ROOT%\light.exe" Burn.wixobj -sice:ICE38
pause
...here is the error:
Burn.wxs
C:\PATH\Burn.wxs(8) : error CNDL0104 : Not a valid source file; detail: The 'Bundle' start tag on line 3 position 4 does not match the end tag of 'BootstrapperApplicationRef'. Line 8, position 7.
I feel as though I am close and am hoping one of you could take a quick peek at the code and give suggestions. It would be much appreciated...
Thanks!
RHH
Your opening BootstrapperApplicationRef element on line 4 is an empty element - it shouldn't end in />.
What are you using to edit your files? Pasting your file into Notepad++ and turning on XML highlighting identified the problem pretty quickly.

MSTest.exe exited with ExitCode 1

I am manually running tests from msbuild/tfsbuild by manually invoking mstest.exe but it is failing unexpectedly with error MSB3073 and ExitCode 1 when I am expecting 0.
I have this target that searches for all DLLs with a postfix of *UnitTests.DLL in the $(OutDir) folder. It builds up a commandline statement that is then executed:
<Target Name="RunUnitTests">
<CreateItem Include="$(OutDir)\*.UnitTests.dll"
AdditionalMetadata="TestContainerPrefix=/testcontainer:">
<Output TaskParameter="Include"
ItemName="UnitTestAssemblies" />
</CreateItem>
<Exec Timeout="120000"
Command=""$(VS110COMNTOOLS)..\IDE\mstest.exe" #(UnitTestAssemblies->'%(TestContainerPrefix)"%(FullPath)"',' ') /testsettings:"$(OutDir)..\..\Sources\mysettings.testsettings"" >
<Output TaskParameter="ExitCode" PropertyName="ExitCode"/>
</Exec>
<Error Condition=" '$(ExitCode)' != '0' And '$(ExitCode)' != '2'" Text="An error [$(ExitCode)] occurred running unit tests." />
<OnError ExecuteTargets="MarkBuildStepAsFailed" />
</Target>
I've added a Timeout property above because some googling suggested this but it didnt make a difference.
This gets equated in the buildlog file as below (quotes included) (the folders names I have changed but left spaces where relevant but they don't look too long):
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\..\IDE\mstest.exe" /testcontainer:"C:\b\someprojectfolder\anotherfolder\Binaries\..\..\debug\some.unittests.dll" /testsettings:"C:\b\someprojectfolder\anotherfolder\Sources\..\..\mysettings.testsettings"
The tests DO run on the build server as part of the build process (i.e. calling the target above) as I can see the test results folder get created on disk. All unit tests pass as expected. I can see the MSTest.exe console output in my build log as well (e.g. Starting execution, list of tests and results, the results file is listed etc)
Additionally I can RDC onto the build server as the build service account and manually run the commandline above using a CMD and it works. (the test results (*.trx) and folder are there).
They also work when I manually invoke the commandline above using CMD them on my local developer machine as myself. It creates the test results file and folders.
FYI We are using Visual Studio 2012 Ultimate on my local machine and installed on the build server as well.
FYI We are using TFS 2012 with an upgrade process definition
I've got a feeling its to do with the "parsing"/escaping of quotes and/or apostrophes or could it be the use of using ..\ in the paths?
I have checked the event log on the build server and it displays no errors/information. Is there any other logs I can check? or properties I can define to "see" the actual error code?
NOTE: I know I could use the <RunTest> style msbuild/tfs build syntaxbut I manual trigger these tests at a more convenient time in the build process
this wasnt to with do quotes or apostrophes in paths. My .testsettings file connects to a remote test controller (on another server running Windows Server 2008 R2). I was collecting all data and diagnostics (video recorder etc, network emulation, event log, system diagnostics etc)
When I checked the event log on the test controller/agent server it was full of errors saying MSTest had to be run as administrative permissions. Thats what i am now investigating.

Apache Ant Build command "Access Denied"

Hey! I am trying to get ant installed and actually already did following this instructions however, I get this error:
Buildfile: build.xml does not exist!
Build failed
which it says there I might get so I just tried executing the next command it says I should(since I'm under Windows it's this one):
build -Ddist.dir=<C:\Ant> dist
anyway I get "access denied" when hitting enter and I can't figure out why. I also tried
build install
and
build install-lite
but I always get that message =/ any ideas why? or what am I doing wrong?
Edit
Without the < > I get a:
'build' is not recognized as an
internal or external command, operable
program or batch file.
Edit2
Well, my ANT_HOME is in C:\Ant and I'm trying to run the command while placing myself on that folder, isn't that correct?
Ant is already installed correctly if you're getting this:
Buildfile: build.xml does not exist!
Build failed
The "build" commands you tried next are only for building Ant from source. You don't need to do this, since Ant is already installed.
In general, the "'XXXX' is not recognized..." means XXXX is not a command/executable, or that it's not on your PATH.
You are taking the < and > symbols too literally. Take them off.
Kind of like C:\Users\<Your ID> the symbols are placeholders.
Are you in the right directory? Do you have something else called build in your path that may be superceeding the build you are trying to call. Can you create a file in that directory?
PROMPT> copy con foo.txt
asdf
asdf
sdf
CONTROL-D
Not sure if this helps but the first question that comes to mind is "do you have appropriate permissions on the file"?