How to get environment variable?

I have an MSBUILD pre-build event that looks at the %COMPUTERNAME% system environment variable and copies different app.config files based on the computer name.

I am passing env.COMPUTERNAME as an enviroment build parameter in my build configuration:

Environment variables

Name Value passed to build
env.COMPUTERNAME %env.COMPUTERNAME%



When my pre-build event runs it is unable to get any value from either %env.COMPUTERNAME% or %COMPUTERNAME%

The build log shows it is not substituting the environment variable with any value :

ECHO COMPUTERNAME is %env.COMPUTERNAME%

How do I reference the %COMPUTERNAME% environment variable value for my MSBUILD pre-build event?

2 comments
Comment actions Permalink

From inside your msbuild file you should be able to use: $(COMPUTERNAME)

0

Please sign in to leave a comment.