Build Variables RRS feed

  • Question

  • Does anyone know a way to create a variable in a build definition that is based on another variable?

    e.g.  I have a variable var1 = "ABCDE" and want to create a new variable var2 equal to "ABC" i.e. the first 3 characters of var1 .


    Tuesday, June 6, 2017 1:34 PM

All replies

  • To clarify: Are you using TFS or VSTS?
    Tuesday, June 6, 2017 7:36 PM
  • VSTS
    Wednesday, June 7, 2017 12:54 PM
  • Your first variable should be sufficient. 
    Wednesday, June 7, 2017 1:03 PM
  • I need to use this variable in one of the build steps

    e.g 'Build Solution' build step expects a path for the solution file. I need this path to include var2 as I don't believe I can use a substring of var1.

    Wednesday, June 7, 2017 3:25 PM
  • You cannot use a substring of var1 directly. If you want to do it, you need to use a script.

    You can use variables in any of the text input fields. They are replaced as macros inline for the string.

    Do click on "Mark as Answer" on the post that helps you, this can be beneficial to other community members.

    • Proposed as answer by Swikruti Bose Thursday, June 8, 2017 10:49 AM
    Thursday, June 8, 2017 10:49 AM
  • Many Thanks for the reply

    I could do this in a script but as I also want to use the variable in the path specified in the 'getsources' step (i.e. BEFORE any build steps are run) I don't see a way of doing this.

    Thursday, June 8, 2017 4:08 PM
  • Currently this is not possible in VSTS.

    Here is a similar user voice has been already raised: https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/17282072-allow-build-variable-to-contain-the-values-of-othe. You can up-vote for the same or you can raise a new user voice for that feature. 

    • Proposed as answer by Swikruti Bose Monday, June 12, 2017 12:09 PM
    Monday, June 12, 2017 12:09 PM
  • Many Thanks.

    I will use up some of my votes for this :)

    Monday, June 12, 2017 4:02 PM