List all Defined MSBuild Variables – Equivalent to set

environment-variablesmsbuild

Is there a way to list all defined variables in an executing MSBuild project?

I'm trying to figure out exactly what paths and variables are set (to pass into WiX), and it's difficult to debug everything. Essentially, I would like something equivelent to running set at the command line. Example:

C:\Users\dsokol>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\dsokol\AppData\Roaming
asl.log=Destination=file
CLASSPATH=.;C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
...

Except that I would like it to list out all of the MSBuild variables (such as Target, OutDir?, and all the crap I've defined in the top of the XML file. Ideally:

$(OutDir)="C:\MyOutDir\bin"
$(ProductVersion)="6.1.0"
$(Platform)="Win32"

Does such a thing exist?

Best Answer

Have you tried running msbuild with with /v:diag command line option? This prints out all of the properties which includes the environment variables and the properties that have been set.