How to enable AnsiColorLogger by default in Apache Ant? - apache

How can I enable the AnsiColorLogger Apache Ant built-in logger by default without running manually command ant -logger org.apache.tools.ant.listener.AnsiColorLogger or adding the environment variable ANT_ARGS ?
I tried to run the command from the ant build.
build.xml
<exec dir="${sdk.dir}" executable="cmd">
<arg value="${sdk.dir}" />
<arg value="AnsiColorLogger.cmd" />
</exec>
AnsiColorLogger.cmd
START -logger org.apache.tools.ant.listener.AnsiColorLogger
Then I run the ant command to compile my project but the logs are not colored.
Fuiba#FUIBA D:\DEV\TEST\proj
> ant
Buildfile: D:\DEV\TEST\proj\build.xml
Trying to override old definition of task for
[exec] Microsoft Windows [Versione 10.0.10240]
[exec] (c) 2015 Microsoft Corporation. Tutti i diritti sono riservati.
[exec]
[exec] Fuiba#FUIBA D:\DEV\TEST\proj
[exec] >
Instead when I run ant -logger org.apache.tools.ant.listener.AnsiColorLogger it works.

When you say you run ant directly it works, how are you running it? From ant's own documentation it doesn't support Windows NT derivatives (including Windows 8 , 10, etc). From your output, it looks like you're running on Windows, so please go into more detail on how to reproduce this problem.
From ant's manual:
Note: It doesn't work on WinNT and successors, even when a COMMAND.COM console loaded with ANSI.SYS is used.
Source: https://ant.apache.org/manual/index.html
If you are running ant from within a terminal that supports ANSI escape sequences, like Cygwin's MinTTY or CMDER, you try passing the env argument to your exec task:
<exec dir="${sdk.dir}" executable="cmd">
<env key="ANT_ARGS" value="-logger org.apache.tools.ant.listener.AnsiColorLogger"/>
<arg value="${sdk.dir}" />
<arg value="AnsiColorLogger.cmd" />
</exec>
Commander: https://cmder.net/
Cygwin: https://cygwin.com/

Related

launching bat file from Izpack installer

Hi I am currently developing a installer with Izpack 5.
I want to execute a bat file from the installer. I added the processPanelSpec.xml in install.xml but the bat file is not starting.
I am geeting this error:
Launserver.bat not found under izpack-dist/target/staging.
It's late and I'm not familiar with izpack, but at work we have an application deployed with it for which we execute a batch at post install stage with:
<pack name="Network Tools" required="yes"
installGroups="Server upgrade,Server installation">
<description>Network rules</description>
<singlefile src="conf/network/firewall.bat"
target="$INSTALL_PATH/tools/firewall.bat"
override="true"/>
<executable
targetfile="$INSTALL_PATH/tools/firewall.bat"
stage="postinstall" keep="false">
<args>
<arg value="$INSTALL_PATH"/>
</args>
</executable>
</pack>
File is no more available after install, I assume this is due to keep="false".

slqcmd query to restore database from disk do not work in ant exec task

I am trying whole evening in this sunday to make this one:
<exec executable="osql.exe" dir="${basedir}" failonerror="true">
<arg value="-U<user>" />
<arg value="-P<password>" />
<arg value="-S<server>" />
<arg value="-QRESTORE DATABASE <database> FROM DISK='<absolute_path_to_database_backup>.bak'" />
<arg value="-b" />
</exec>
As suspected, the
<arg line=""/>
also do not work. :(
into the same call, only using sqlcmd utility. Unforutinetly all I can get is the error message from ants executed sqlcmd that there is "Unexepcted attribute. Consult help -?".
[exec] Sqlcmd: '-Q"RESTORE DATABASE <database> FROM DISK='<absolute_path_to_database_backup>.bak'"': Unexpected argument. Enter '-?' for help.
BUILD FAILED
C:\SVN\Ver_trunk\Upgrade\build.xml:72: exec returned: 1
Actual names are replaced with <> brackes.
My PC software configuration:
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
Apache Ant(TM) version 1.8.3 compiled on February 26 2012
Any help highly appreciated to make the correct syntax for this sqlcmd ... :)
Okay, here is the summary of the things I had to do to make it work ( at least from Jenkins :( ):
use <arg line="" /> syntax, not <arg value="" />
escape path by additional /
re-configure my workstation by suggestions here: http://social.msdn.microsoft.com/Forums/en-US/sqlsetupandupgrade/thread/3a2af602-75fe-4f9c-a795-733a228e7f30/

Set MSBuild Web Publish Property "ExcludeGeneratedDebugSymbol" from Command Line

I'm using NAnt to build my project and publish web site project(s). I'd like to include the PDBs in the resulting package. How can I set the ExcludeGeneratedDebugSymbol property from the command line when I execute msbuild?
I tried adding it to the list of parameters but I'm not seeing the PDBs still. My exec task looks like this:
<exec program="${MSBuildPath}" workingdir="${path::get-full-path(PublishWebProject.SourcePath)}\">
<!-- Don't show the logo. -->
<arg value="/nologo"/>
<!-- Build w/o Clean -->
<arg value="/t:Build"/>
<!-- Configuration, Output, Options, No Warnings -->
<arg value="/p:OutputPath=bin\;OutDir=${path::get-full-path(PublishWebProject.OutputPath)};Configuration=${Configuration};Platform=Any CPU;UseWPP_CopyWebApplication=True;PipelineDependsOnBuild=False;WarningLevel=0;RunCodeAnalysis=false;ExcludeGeneratedDebugSymbol=false"/>
<!-- Quiet -->
<arg value="/v:q"/>
<!-- Project Path -->
<arg value="${PublishWebProject.ProjectFileName}"/>
</exec>
And here is the actual call to MSBuild:
[exec] Starting 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe (/nologo /t:Build "/p:OutputPath=bin\;OutDir=D:\Projects\XYZ\Publish\Release-Production\CommonWeb\;Configuration=Release-Production;Platform=Any CPU;UseWPP_CopyWebApplication=True;PipelineDependsOnBuild=False;WarningLevel=0;RunCodeAnalysis=false;ExcludeGeneratedDebugSymbol=false" /v:q CommonWeb.csproj)' in 'D:\Projects\XYZ\Source\CommonWeb\'
Which would equate to:
D:\Projects\XYZ\Source\CommonWeb> C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe /nologo /t:Build "/p:OutputPath=bin\;OutDir=D:\Projects\XYZ\Publish\Release-Production\CommonWeb\;Configuration=Release-Production;Platform=Any CPU;UseWPP_CopyWebApplication=True;PipelineDependsOnBuild=False;WarningLevel=0;RunCodeAnalysis=false;ExcludeGeneratedDebugSymbol=false" /v:q CommonWeb.csproj
I've also tried setting the UseWPP_CopyWebApplication to false but this didn't help either.
Your project file contains information on output debug info. Try setting debug info to pdb-only:
<arg value="/debug:pdbonly" />

MSBuild a .dbproj seems to run twice

When we build our Visual Studio 2010 Database Project from the command line using msbuild.exe it can sometimes run twice from the same command line.
We call msbuild from a nAnt script, and just call the 'Build' target. Our database project is quite large so it can take about 4 mins to run through a single time. When it runs through twice our database build takes over 8 minutes.
Here is the exec section we use to call the build. It runs on a .sln file that only has a single .dbproj in it.
<exec program="${framework::get-tool-path('msbuild.exe')}" append="true" failonerror="true" verbose="true">
<arg value="${database.sln}" />
<arg value="/p:OutputPath=${build.output.database}" />
<arg value="/nologo" />
<arg value="/t:Build" />
<arg value="/p:Configuration=Release" />
<arg value="/p:WorkingDir="."" />
<arg value="/verbosity:normal" />
<arg value="/v:m" />
</exec>
The output we get looks like
Creating a model to represent the project...
Loading project references...
Loading project files...
Building the project model and resolving object interdependencies...
Validating the project model...
(x) problems have been detected.
[a list of warnings based on the db analysis]
The results are saved in (y).
Creating a model to represent the project...
Loading project references...
Loading project files...
Building the project model and resolving object interdependencies...
Validating the project model...
(x) problems have been detected.
[a list of warnings based on the db analysis]
The results are saved in (y).
Can anyone help as to why the target seems to be called twice (only sometimes - I haven't figured out why only sometimes). The script always runs on an empty folder structure so there is never a build output left over from a previous run of the build.
First of all try to change the output verbosity to diagnostic for MSBuild:
<arg value="/v:diag" />
And the same for the Ant script. I don't have experience with Ant , but you shpould know how to do it ;)
Hopefully you will find a reason in the diagnostic logs...
BTW:
You have duplicate command line options for MSBuild. Remove one arg from the following:
<arg value="/verbosity:normal" />
<arg value="/v:m" />
/v is abbreviation for /verbosity see MSDN for MSBuild command line options reference.

MSBuild failing for CruiseControl 1.6

G'day.
We've updated to ccnet 1.6 due to our TFS server being upgraded to 2010.
Within our ccnet.config we're executing a nant (0.9) build script that contains an MSBuild exec task.
Running MSBuild at command line with the parameters as specified by the nant script works okay, but for some reason when ccnet executes the MSBuild task via the nant script it fails with the following:
External Program Failed: C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe (return code was 128)
The nant exec task:
<property name="MSBuildPath" value="${framework.dir}\MSBuild.exe"/>
<exec program="${MSBuildPath}">
<arg line="${project.svds}.sln" />
<arg value="/t:Rebuild" />
<arg value="/p:Configuration=Release" />
<arg value="/p:Platform=x86" />
<arg value="/verbosity:normal" />
<arg line="/logger:'C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll'"/>
</exec>
Unfortunately no more is revealed and it's all rather cryptic.
128 There are no child processes to wait for.
Set MSBuildPath as below and try...
<property name="MSBuildPath" value="C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe" />
This thread might help you.
EDIT
Possibly this can be due to the service user account. It may be running as the Local System account. Changing the service account - via Control Panel / Administrative Tools / Services may help.