User Variables / Set an internal variable

Sysprogs forums Forums VisualGDB User Variables / Set an internal variable

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #31382
    ChangedDaily
    Participant

    Hi,

    I have defined a User Variable called “FirmwareVersion”, given it a default value. I am then trying to use a Custom Build Step (“Before building”) to set a new value prior to build with the “x=set an internal variable” action. When I use the test the command it says the variable was set but the value does not get through to the build where it is referenced like this in the MSBuild settings:

    VERSION_STRING=”\””$(FirmwareVersion)””\”

    My goal is to have one place to set a firmware version string that can be used in the application code but also be used to append to the output filename, e.g. APP-V01.01.01.bin, and be common to multiple configurations.

    The default value does find its way through to the application. I thought I was close!

    Any help appreciated, thanks

     

    #31389
    support
    Keymaster

    Hi,

    Indeed, the MSBuild-level properties are separate from the VisualGDB variables and are not automatically inherited.

    The easiest way to achieve what you have described is to programmatically generate an MSBuild property sheet defining the necessary variables. You can reference the property sheet from one or more projects, and can invoke the tool generating it as a custom pre-build step.

    Another option would be to simply generate a header file with the relevant definitions, and include it from the projects.

    #31419
    ChangedDaily
    Participant

    Hi,

    Thanks, I have created a new property sheet which can be seen by multiple projects/configurations, that bit is working. I don’t understand how to ‘invoke a tool to generate it’ though. Please can you explain further?

    Creating a header file with the version information is of course very easy but how can I use the definitions in the header file in VisualGDB?

    Thanks

    #31422
    ChangedDaily
    Participant

    Hi,

    Actually going back to my original question, I created a “User Variable” in the VisualGDB settings.  The default value is propogated to the build system OK but not updated in the “Before building” action. If the VisualGDB value is updated why is that not then set in the “VERSION_STRING” in my example?

     

    Thanks

     

    #31424
    support
    Keymaster

    For MSBuild projects, the VisualGDB-level variables should not be automatically propagated to MSBuild level, unless you configured some mechanism to do it manually. If you can share the screenshots of your setup (how you configured the variables and how do you observe them propagated), we will try to explain what is going on.

    #31426
    ChangedDaily
    Participant

    Hi,

     

    Please find attached screen shots of settings, I have not configured any special mechanism; set User Variable with a default value, then use it in the MSBuild settings page.

     

    Thanks

     

    Attachments:
    You must be logged in to view attached files.
    #31430
    support
    Keymaster

    Thanks for the clarification. The user variables defined via VisualGDB Project Properties indeed work differently. Their values are saved to the .user file each time you edit them via VisualGDB Project Properties, and are read throughout the build process.

    The variables set via custom build/debug steps only persist until the end of the corresponding operation. For non-MSBuild projects that would be the entire build. For MSBuild-based projects they are guaranteed to persist between multiple pre-build steps in the same sequence, but not between pre-build steps and the actual build.

    #31453
    ChangedDaily
    Participant

    Hi,

    I have managed to share a variable between VisualGDB and the MSBuild system by using an MSBuild Property sheet which is visible in all configurations and importing this sheet to VisualGDB settings.

     

    Patrick

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.