简体   繁体   中英

TFS: Access a local variable used in build template in a powershell script

i have customized my build template to increment the assemblies version number.

I need a local variable i created/use during the build in a powershell script that is run after the build.

The local variable i created in the build template is called VersionNumber of type string. I would like to use that variable value in a powershell script that is run post build.

How can i do that?

As your question reflect it seems that you are trying to run powershell script soon after your build definition. If that is the case then:

In your build definition you must creating new folder each time the build has been done.

you may use your variable name(which u want to extract) in your folder name(as your variable contains version number).

Then in your powershell script you may sort the folder by datetime and can pick up the folder name (which contains version number) and can use it.

It's also suggested to use your folder name by version number.

As a workaround, you can pass the value as a script parameter to your post-build PowerShell script:

在此处输入图片说明

Your script would accept the parameter like so:

# script.ps1
param([string] $MyParam)

# the rest of your script

I also would prefer to be able to access the build template directly. If I learn how, I will post another answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM