One of the great features that TFS 2015 Update 2 brings to the party is the ability to add extensions and custom build tasks.
I was sorely missing the SQL dacpac deployment task that has been available on VSTS for a while, so I decided to upload it myself.
First of all, all the source for the VSTS / TFS build tasks is actually available. If you have not already, head over to Microsoft’s GIT repository and take a look for yourself. You may notice that the SqlServerDacpacDeployment is just sitting there, ripe for the picking…
To get the build tasks uploaded to your on-prem is not as straight forward as it would seem though. First of all, you need the TFS Cross Platform Command Line (tfx) command line utility to upload the build tasks. It in turn requires NodeJS. Once all that is installed you can start uploading your extensions and build tasks… well almost.
Tfx does not yet support integrated authentication, and on-prem versions of TFS do not yet have “Personal Access tokens” or PATs. Tfx does however support basic authentication, which means we need to tweak our TFS instance a bit to be able to upload our own tasks.
We need to get onto the TFS server and open up IIS. Select the “tfs” application under the Team Foundation Server site and enable basic authentication.
Once you have done that you are ready to upload your tasks. After downloading the task repo from Microsoft I simply opened up a command prompt and executed the following command :
tfx build tasks upload –service-url http://<<server>>:8080/tfs –auth-type basic –username <<username>> –password <<password>> –task-path .SqlServerDacpacDeployment
Interestingly enough that did not work, for the life of me I could not see the task in the list. I eventually figured out that in the task.json manifest there was a “visibility” section. The first item was “preview” and this seemed to stop the task from being “shown” somehow. After removing that it worked like a charm.