Pre-Build Step Use MSBuild Property?

Sysprogs forums Forums VisualGDB Pre-Build Step Use MSBuild Property?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #29092
    Seidleroni
    Participant

    I am using VisualGDB on a build server and would like to be able to pass in a version parameter to my pre-build step. I see it is possible to set a MSBuild property (/p:BUILD_VER=5) when I create a build. Is it possible to capture this property and pass it to the pre-build step somehow? If not, is there another way to do something similar?

    #29094
    support
    Keymaster

    Hi,

    Unfortunately, MSBuild doesn’t automatically pass custom properties to tasks (you can do it explicitly by patching the .targets files, but it’s generally not recommended). The easiest workaround would be to pass the setting via an environment variable. VisualGDB expands the environment variables together with the internal variables, such as $(ProjectDir).

    #29095
    Seidleroni
    Participant

    How would this be done, then? I have my Build Server pre-build step that executes a command line to say “set BUILDVER=5”, but when it calls msbuild, wouldn’t that environment variable no longer be active since its in a separate command line window because it is a separate build step?

    • This reply was modified 4 years, 3 months ago by Seidleroni.
    #29097
    support
    Keymaster

    This is something to check with your build server documentation. From the VisualGDB side, as long as it’s launched with the correct environment, it will expand the variables as expected. You can try experimenting with .bat files, however as this is generally something outside VisualGDB’s control, the help we can provide with it is somewhat limited.

    #29100
    Seidleroni
    Participant

    Fair point. For someone (or me!) who is looking at this in the future, TeamCity sets a bunch of environment variables by itself, so the pre-build step can inspect to see if the environment variable exists or not, and use that. TeamCity sets BUILD_NUMBER to the build number as well as other variables that may be useful such as the commit hash, project name, etc. To see what is available, have the build server send “set” so the log will contain all the environment variables.

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