Get the current logging verbosity level in my MSBuild script -


our msbuild scripts use exec task call few command line applications. of these applications have own output verbosity settings have same verbosity level of msbuild script calling them.

is there way me logging verbosity level of msbuild process?

i thought write custom task handle this, poking around msbuild api, couldn't find properties or classes give me verbosity level.

shortly after asking questions, noticed msbuild 4 exposes system.environment.commandline property function, should include verbosity arguments. following bit of parsing, can create several boolean properties tell current logging level:

<propertygroup>   <commandline>$([system.environment]::commandline.trim().tolower())</commandline>   <isquietverbosity>false</isquietverbosity>   <isminimalverbosity>false</isminimalverbosity>   <isnormalverbosity>true</isnormalverbosity>   <isdetailedverbosity>false</isdetailedverbosity>   <isdiagnosticverbosity>false</isdiagnosticverbosity>  </propertygroup>   <propertygroup condition="'$(commandline.contains(&quot;/v&quot;))' == 'true'">   <indexoflastverbosityarg>$(commandline.lastindexof("/v"))</indexoflastverbosityarg>   <indexofverbosityarg>$(commandline.indexof(":", $(indexoflastverbosityarg)))</indexofverbosityarg>   <indexofverbosityarg>$([msbuild]::add($(indexofverbosityarg), 1))</indexofverbosityarg>   <indexofendofverbosityarg>$(commandline.indexof(" ", $(indexofverbosityarg)))</indexofendofverbosityarg>   <indexofendofverbosityarg condition="'$(indexofendofverbosityarg)' == '-1'">$(commandline.length)</indexofendofverbosityarg>   <lengthofverbosityarg>$([msbuild]::subtract($(indexofendofverbosityarg), $(indexofverbosityarg)))</lengthofverbosityarg>   <verbositylevel>$(commandline.substring($(indexofverbosityarg), $(lengthofverbosityarg)).trim())</verbositylevel>   <isquietverbosity>$(verbositylevel.startswith('q'))</isquietverbosity>   <isminimalverbosity>$(verbositylevel.startswith('m'))</isminimalverbosity>   <isnormalverbosity>$(verbositylevel.startswith('n'))</isnormalverbosity>   <isdiagnosticverbosity>$(verbositylevel.startswith('di'))</isdiagnosticverbosity>   <isdetailedverbosity condition="'$(isdiagnosticverbosity)' == 'false'">$(verbositylevel.startswith('d'))</isdetailedverbosity>  </propertygroup> 

remember, work in msbuild 4+.

ugly? yup. kludgy? maybe. work. yup!


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -