0
votes

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?

2
Are you kicking off the powershell script from within the build template? - Isaiah4110
well it's triggered by setting the Post-Build script path information in the Advanced section of the build process parameters... - user1161137
why are ppl down voting this question? - user1161137
What are you trying to do with your PS script? It might be as simple as kicking off your PS from within the template using an InvokeProcess activity, VersionNumber string should be available to be passed to the activity. Am not sure, I didnt down vote it. - Isaiah4110
well i'm not using a nuspec file to create nuget packages on CI builds.. and it seems that nuget packaging doesn't like the fact if you don't change AssemblyVersion attribute (i'm auto incrementing the AssemblyFileVersion), it won't use that for the nuget package. so i wanted to pass the version number to a ps script post build on the tfs build server. - user1161137

2 Answers

0
votes

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.

0
votes

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

enter image description here

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.