Alexander Vanwynsberghe

"There is nothing impossible to him who will try"

What’s new in TFS 2013 Build?

29 Comments

  • Reply Bhushan Gawale |

    This is awesome ..

    How about integration of Continuous Deployment with Windows Azure Cloud Services? are there any upcoming features in build system to achieve that as well ?

  • Reply Daniel Schroeder |

    This looks very nice. One thing I don’t like about the default build template though is that it associates a build to the work item before actually trying to do the build, so even if the build fails the work items get updated. This was a sore point for our QA team as they would assume that if they see an “Integrated In Build” version that it meant the bugfix/feature was actually in a build and ready to be tested; so I modified our build template to make this one of the very last steps to complete, and only if the build passes successfully.
    The Git integration and Pre/Post build scripts are a very nice addition, as I would much prefer to work in PowerShell than Workflow (as long as it is still easy to call the TFS activities from PowerShell). I’m wondering how easy is it though to pass custom parameters that we add to our build templates to the Pre/Post build scripts?
    Also, your link to the list of TF Build environmental variables accessible from PowerShell is broken.

    • Reply Alexander Vanwynsberghe |

      You cannot really “configure” those environment variables. TFS Build will pass the correct value to the variable. You can of course use the script arguments to pass additional arguments to your script.

      • Reply Durga Prasad |

        for some reason I am getting below error when run the script.

        Script is:

        Write-Host “Hello Poweshell script.“

        $testdata =“The build definition name is “$Env: TF_BUILD_BUILDDEFINITIONNAME

        $testdata >> “C:temp1log.txt”

        Error:
        Unexpected token ‘Env:’ in expression or statement.

        At C:Builds1Training PortalSystem TestsrcBuildProcessTemplatesscriptssy

        stemtest-postbuild.ps1:3 char:48

        + $testdata =”The build definition name is “$Env: <<<< TF_BUILD_BUILDDEFINITIO

        NNAME

        + CategoryInfo : ParserError: (Env::String) [], ParentContainsErr

        orRecordException

        + FullyQualifiedErrorId : UnexpectedToken

      • Reply Daniel Schroeder |

        One other thing to note is that you can pass your own custom environmental variables into your scripts as well, by modifying the “Run optional script…” activity in the default template. This is handy if you have other customized variables in your build template that you want to pass into the script, not as a parameter. It’s also worth mentioning that while you can read these environmental variables in your script, if you write to them the changes do not propagate back to the build template. For example, if you change the TF_BUILD_DROPLOCATION environmental variable, it will still copy the binaries to the original drop location.

  • Reply Naeem |

    Nice article but I have a question, if we have couple of builds running against a branch, we would like to have some global parameters that will help in organizing the builds. That’s very simple in TeamCity where we can define global parameters, and we can use that everywhere, and anytime can change in a single place but I cannot see anything like that in TFS 2012.

    Is there any way to do so? so far nothing found, and I don’t want to customize the template to read those global parameters from some file on source control, unless there is no other way to do so.

    • Reply Alexander Vanwynsberghe |

      Hi Naeem, what you can do is using PowerShell to get those values? You can for example store them in source control, and get them using PowerShell (you get the source control directories using the “$Env: TF_BUILD…” variable in PowerShell)..

      Good luck!

      • Reply Naeem |

        Hi Alexander, thanks for your post, yea that’s one way of doing this, I am still trying to see what should be the best way to do so.

  • Reply Christopher Painter |

    Any ideas on where I can get this v12 of the default template? I’m using VSOnline and when I create a new project it creates a v11.1 default template that is lacking the script injection points

    • Reply Alexander Vanwynsberghe |

      Hi Christoper, you need to use the TfvcTemplate.12.xaml on VSOnline (see screenshot). This template contains everything you need. Good luck!

  • Reply Max |

    Thank you for the post. One of the primary reasons we use custom template is to set specific version to our DLL. Basically, we modify AssemblyInfo.cs before building the project. Is there any standard ways now in TFS 2013 to do this task?

  • Reply Michael Sparks |

    Simplified Build process template for who? We have been using the parallel process template Patrick Carnahan developed for TFS 2010. I also modified it to work with TFS 2012. http://blogs.msdn.com/b/jimlamb/archive/2010/09/14/parallelized-builds-with-tfs2010.aspx

    It appears that this “simplified” process template has rolled up the logic from several activities from TFS 2010/2012 into other base activities for 2013 Build.

    See my post here: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/ef8b912a-0beb-48ae-93cf-d75411e9d8a1/tfs-2013-parallel-build-process-template?forum=tfsbuild

  • Reply Bruce Cutler |

    I have a post-build script that appears to have run. It outputs a lot of information, where can I see it?

    • Reply Daniel Schroeder |

      You should be able to view it in the build’s log. It won’t show up in the Summary view though. You will need to look at the Log or Diagnostic view of the build log, which is available through the Team Web Access’s Builds tab.

  • Reply Tal |

    How can I run a .BAT script? I would like to copy few files and directories from the SourceDirectory to the DropLocation. I’m using asConfigured for Output location. I was trying to supply the batch file with CLI arguments and to use it with %1, %2 etc. But since I get very limited information in the LOG regarding the failures I could not resolve this.

    • Reply Daniel Schroeder |

      Instead of using a .bat file, use a PowerShell .ps1 file to do the copy, and specify that .ps1 file in the Post-Build script path as shown in the post. Both the Sources and Drop Location are available in the PowerShell script as environmental variables, as Alexander showed above.

      @Alexander it looks like MS changed the link to the environmental variables on you again. The new link is at http://msdn.microsoft.com/en-us/library/hh850448.aspx

      • Reply Tal |

        Hey, Thanks but I’m still with .BAT :-(
        and I still need to convert the $(TF_BUILD_DROPLOCATION) and $(TF_BUILD_BUILDDIRECTORY) to %1 etc, while adding some custom parameters as well.

        Do you have an Idea for me?

        • Reply Daniel Schroeder |

          You could just have your PowerShell file call the .bat file using:

          start-process “cmd.exe” “/c C:Pathfile.bat”

          If you don’t want to use PowerShell at all for some reason (I don’t know why that would be), you can always modify your build template. Basically you open the DefaultTemplate.xaml in Visual Studio and it should open the Windows Workflow. Then you can drag an Invoke Process item from the Toolbox. In that control you set the process to execute as “cmd.exe” and for the arguments specify something like:

          “/c C:Pathfile.bat ” + Build.SourcesDirectory + ” ” + Build.DropLocation

          and then check that .xaml file back into source control.

  • Reply SAM |

    Can we have generalised build definition(BD) catering to all project if not that then environment?

    In my org I have project A, B And C. Each has DEV /Test/Production environment.So I have got( 3 Projects* 3 Environments=)9 Build definition(BD) to be created which I don’t want to .Can we have generalized BD which will serve all these 9 testcases?
    BD is defined on XAML code which takes input like sln or project file which will be different for different project like A.sln,B.sln and C.sln so I understand it not feasible to have generalized BD at project level. (Untill and unless I learn more about XAML code)
    So My aim is to serve 3 Test cases i.e 3 Environment for each Project .I want to have 3 BD catering to dev/prod/test environment. like BD called Build_A will take care of deployment to Prod/DEV/TEST environment automatically depending on who triggered a build.I created a XML file which stored all environment details .
    My Solution to a problem:: Find who triggered a build; lets say (DEV team member); then load Dev environment from XML and execute code(which is same for DEV TEST and PROD). if QA team member triggered a build then run on TEST environment loading details from XML.
    1.Can any one suggest any other way to sort out this thing?
    2.How to identify who triggered a build (Using their mail id linked to TFS) in powershell?I mean how to get mail id of a person who triggers a build in powershell?

    below is XML code::

    ServerTST
    DomainTST\CredTST
    TST@123
    C:\inetpub\wwwroot\TST

    ServerTST2
    DomainTST\Cred2
    TST2@123
    C:\inetpub\wwwroot\WebAPI\TST2

    ServerDEV
    DEVDomain\CFRED_DEV
    DEV@123
    C:\inetpub\wwwroot\WebAPI\DEV

    </Environment

  • Reply SAM |

    AJGUSHC2SP02VT.AJGCOTST.INT
    ajgcotst\s-dspfarmadmin
    SMART_UKCC_TST_Password.txt
    C:\inetpub\wwwroot\WebAPI\UKCCTST

    AJGUSHC2SP03VT.AJGCOTST.INT
    ajgcotst\s-dspfarmadmin
    SMART_UKCC_TST_Password.txt
    C:\inetpub\wwwroot\WebAPI\UKCCTST

    ajgushc2sp11vd.ajgcodev.int
    ajgcodev\s-dspfarmadmin
    SMART_UKCC_DEV_Password.txt
    C:\inetpub\wwwroot\WebAPI\UKCCDEV

    </Environment

Post a comment