Putting build information into compiled builds.

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 9 months and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
ryanhebb
Posts: 2
Last visit: Tue Sep 19, 2023 1:37 pm

Putting build information into compiled builds.

Post by ryanhebb »

Product, version and build: Powershell Studio 2023 5.8.221
Operating system: win 11 22h2
PowerShell version(s):5.1

I've built my first powershell application and it works great, I'm trying to version the software so I always know which version the user is on. in the build settings you can manage this this in the Version Information section with File version, and Product version. you can even check the box for "auto-increment file and product version" which sounds great. I'm just wondering if there is a way in the powershell code to reference this value automatically from the file to present the user with the current build version?
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 1:00 pm
Answers: 39
Been upvoted: 30 times

Re: Putting build information into compiled builds.

Post by brittneyr »

You can get the product version information for a running packaged executable from the following line:
  1. [System.Windows.Forms.Application]::ProductVersion
If you are not running the packaged executable, you can get the product version from the exe file.
The following may be helpful:
https://stackoverflow.com/questions/306 ... powershell
Brittney
SAPIEN Technologies, Inc.
ryanhebb
Posts: 2
Last visit: Tue Sep 19, 2023 1:37 pm

Re: Putting build information into compiled builds.

Post by ryanhebb »

Thanks your reference mirrors how I ended up solving it as well:
(My app name is Populeateeid.exe, Line 1 finds the process exe wherever they launched it from and shows information for the most recently launched copy. then populates my label lblver with the content of the product version from the file property)

$pathtofile = (get-process populate*eid* | sort starttime | select -First 1).path
$lblver.text = (Get-ItemProperty -Path $pathtofile).versioninfo.productversion
This topic is 9 months and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.