Outputting environment variables from MSBuild .targets files -
suppose had .targets files called part of long chain of build related scripts, , used environment variable. suggest way debug build process , check variable's value once file reached build process?
environment variables "read" msbuild @ start of build process, i.e. when invoke msbuild.exe. accessible properties same name environment variable (e.g. $(path)
).
thus, sufficient list variables right @ startup, if need known values of environment variables. in general start msbuild /v:diag
. output like:
microsoft (r) build engine version 14.0.25420.1 copyright (c) microsoft corporation. rights reserved.
c:\program files (x86)\msbuild\14.0\bin\msbuild.exe /v:diag .\clrinfo32.csproj build started 12.07.2016 14:51:35. environment @ start of build: activelanguage = en-us allusersprofile = c:\programdata appdata = c:\users\foobar\appdata\roaming ...
note however, value of environment variable stay same whole build process (*), interesting question value of msbuild property (that has been initialized value of environment variable @ start of build) @ point in time during build process.
property values can overwritten (by specifying on command line, setting explicitly in <propertygroup>
-elements, etc.). order of evaluation significant.
if need know value of property during task's execution, using <message importance="high" text="$(myproperty)"/>
sufficient. other that, note msbuild execution can debugged.
(*) assuming know custom task setting using environment.setenvironmentvariable()
behind scenes. in turn doesn't change value of property has been initialized variable @ start of msbuild.
Comments
Post a Comment