Leave a Reply


  1. Thanks a lot for this post Peter! It was the missing piece in our TFS build workflow.

    Do you know what kind of permissions the user needs to have to push those tasks? Only our TFS administrator is allowed and we’d like to share the rights without giving administration permissions. We have this error message:
    “Access denied. {userLogin} needs Manage permissions to perform the action. For more information, contact the Team Foundation Server administrator.”

    jdebarochez Reply

  2. You’re quite welcome, glad it helped. You have to be in the ‘agent pool administrators’ group, or TF admin to be able to upload tasks.

    Peter Toonen Reply

  3. I love this article! This is exactly what I needed.

    Couple of questions.

    1. Does every TFS 2015 server have the “_apis/distributedtask/tasks/”, as used in your upload powershell script? I try to hit http://mytfsserver/_apis/distributedtask/tasks with a web browser, and I get nothing. I will check IIS for that folder, but I wonder if every on-premise TFS 2015 server should have this?

    2. What do you think about using (zipping up) the build tasks made by Microsoft for VSO, instead of creating my own like your article has. (https://github.com/Microsoft/vso-agent-tasks/tree/master/Tasks/NugetPackager and https://github.com/Microsoft/vso-agent-tasks/tree/master/Tasks/NugetPublisher).

    Thanks for this well written and detailed article!

    Steve K.

    Steve Kennedy Reply

    • Hi Steve,

      To answer your questions:

      1) Yes, every TFS 2015 server should have those files, mind you that they’re under the /tfs virtual application/directory. So it would be something like http://yourtfsserver:8080/tfs/_apis/distributedtask/tasks

      2) At the time I wrote this article those tasks were not yet available and I used NuGet packaging as an example, I would of course recommend to use the Microsoft supplied tasks. These two tasks will be in TFS from update 1 on (install and play with the RC if you haven’t yet).

      3) You should have that folder, but as I said under 2, it will be under the /tfs virtual directory.

      On another note, since writing this article, a new utility has come into play: https://github.com/Microsoft/tfs-cli You can use this utility to easily upload tasks to your server.



      Peter Toonen Reply

      • Thank you so much for your answers! I really appreciate it. With your help, I finally was able to get everything working. Thanks again!

        Steve Kennedy Reply

  4. Eek.

    3. If I don’t have the “_apis” folder on my TFS server, is there another way to upload the task to the server? Meaning, are these tasks stored in the local file system somewhere on my TFS server?

    Steve Kennedy Reply

  5. A very good article, worked perfect to me. Just one question.
    If I like to import a .net Assembly in powershell, where can I place this exclusive assemblies? Or isn’t that an option?


    Ralf Reply

    • Thanks! If it’s a non-default assemblies, you have several options:

      1) Install it onto every build server (using a SDK for example) you will use. This may work well if you have control over all build servers, but might not be your best solution.
      2) Place the assembly in some sort of artifact repository, where your task will download it from whilst running and then discard it after the build.
      3) Include it into your task. Take a look at the SonarQube pre-build task for an example:

      My personal preference would be 2. That keeps the task light-weight and allows you to update the assemblies without updating the task – providing the assembly’s public API doesn’t change of course.


      Peter Toonen Reply

  6. I am using the TFS 2015 with update 1 ISO to install on a Windows 2012 R2 server with SQL Server 2014. When I launch the install process and select “Full Server”, the “Build” item in the left hand list, which is supposed to appear under the “Application Tier” item, is missing.

    What is happening ?

    Joshua Reply

    • In TFS 2015 the build has drastically changed: https://msdn.microsoft.com/Library/vs/alm/Build/overview

      This also means that in the installer, the ‘build’ option has been moved to ‘Additional Tools and Components’. The (legacy) XAML build is now ‘Configure XAML Build Service’. New (tfs 2015) build-agents can be installed after the installation.

      Peter Toonen Reply

  7. Thank you a lot for a knowledge sharing. Your upload script works perfectly
    Could you please advise how to delete created tasks using api request?

    Yegor Reply

    • Thanks Yegor,

      you can use the following powershell script to uninstall.

      [PSCredential]$Credential = (Get-Credential)

      # Gather the necessary information
      $taskDefinition = (Get-Content $taskPathtask.json) -join "`n" | ConvertFrom-Json
      $headers = @{ "Accept" = "application/json; api-version=2.0-preview"; "X-TFS-FedAuthRedirect" = "Suppress" }
      $url = "$TfsUrl/_apis/distributedTask/tasks/$($taskDefinition.id)"

      # Perform the actual request
      Invoke-RestMethod -Uri $url -Credential $credential -Headers $headers -Method Delete

      The parameter ‘TaskPath’ refers to the directory which contains the unzipped task definition.

      – Peter

      Peter Toonen Reply

  8. Great post. Created a custom task, it is showing in the database but not visible in the builds. what could be the wrong?

    4SB Reply

    • First thing that pops to mind is that the task category is incorrect (non-existing). If that’s the case, just re-upload.

      – Peter

      Peter Toonen Reply

  9. It shows up now.. not sure how and why.

    4SB Reply

  10. […] P.S. ????????? ?????????? ? ???????? ??????????? build-task ? ???????? ?? ? TFS ????? ????? ?? ??????: https://blogs.infosupport.com/custom-build-tasks-in-tfs-2015/ […]

    ????????? ??????? ?????? ? email-??????????? ?? TFS 2015 (scripted builds) | ???? ???????? Rubius Reply

  11. […] followed closely the design guidance found here, here and here, but I keep getting this PowerShell […]

    TFS 2015.3 custom build step not sending variables to the script | Codeba Reply

  12. Thanks
    I cant see how the task is “published” into the TFS server ?
    What am I missing or cant see ?


    Greg Roberts Reply

  13. hi my custom task is not picking any agent

    Sandeep Reply

  14. Hi I am getting this error:
    VSTS task module not found at expected location: C:TfsDataAgentsAgent-customtasktasksSandeepTask.1.0ps_modulesVstsTaskSdkVstsTaskSdk.psd1

    Sandeep Reply

  15. please help me on creating new category.

    Sandeep Reply