From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I properly update a default value at build time?

I'm trying to hard-code some version information into my application at build time. I want this version information to updated automatically (eg no manual changes required by the developer, the build system simply looks at the code to determine version info automatically), and also immutable, so should not be determined from a config file (since that could be modified after application deployment).

 

The solution I've implemented is to put the required data into a control, and as part of the pre-build action, update the default value of this control.

 

This has worked, but occasionally I get the following error: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000kEssSAE&l=en-US

 

The VI has changed on disk since last saved or loaded by LabVIEW. 
If you load its front panel, it will probably be inconsistent with the parts of the VI already in memory, resulting in a corrupt VI. 

This seems to be because the prebuild action is *saving* the VI *during* the build process. The fix I've implemented is to have the pre-build action do it's VI saving, and then error out to cancel the build, and then when it notices the control is already updated, essentially to do nothing, but the error remains.

 

I'm stuck at this point, how do people do this?

 

I've attached the pre-build action I use, if that's helpful!

0 Kudos
Message 1 of 6
(1,054 Views)

Set the desired version number in the build specification and use vi.lib\Platform\fileVersionInfo.llb\FileVersionInfo.vi to get the version from your exe. Following code should work:

LucianM_0-1622579569086.png

 

Lucian
CLA
Message 2 of 6
(1,035 Views)

The versioning used by LabVIEW is not the versioning scheme we intend to use. We need commit-level details in this control, so we need to do it in a different way.

0 Kudos
Message 3 of 6
(1,023 Views)

I have done something similar for real-time and FPGA apps where existing versioning tools don't help. I used a global to store the version number, build date and time. Then updated the default values as part of the Pre-build. I've not had any issues with this method although for those apps I'm still back in 2016.

 

I did wrap up the global as a private member of a library with an API to get the values (called by the application) or to save new defaults (called by the Pre-build).

0 Kudos
Message 4 of 6
(1,002 Views)

I have tested your VI by replacing the missing subVI by an hardcoded revision value and it worked just fine.

 

I would have done differently though. With scripting you can directly set the values of constants in the diagram.

Here is an example project where I modify a diagram constant in the prebuild of an executable :

0 Kudos
Message 5 of 6
(978 Views)

Personally, I would prefer to use tags.  Maybe something like this:

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 6
(967 Views)