How to limit build task only to VSTS not TFS

136 views Asked by At

I have a VSTS extension with two build tasks, one build task should be available for both VSTS and TFS, the other one only for TFS. Is it possible to configure this for each build task via extension manifest?

3

There are 3 answers

3
Bandara On BEST ANSWER

I have used the following workaround to display message and discontinue the build in TFS.

var collectionUrl = process.env["SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"];
var regExpression = new RegExp("^((https?)\:\/\/)(([a-z0-9])+\.)*(visualstudio\.com)");
if(regExpression.test(collectionUrl))
{
    //VSTS Detected
}
else
{
   //Display message task not compatible with TFS
   //Fail the build
}
4
Cece Dong - MSFT On

Make the extension manifest indicates that the extension is available only for Team Services (targets = Microsoft.Visualstudio.Services.Cloud).

0
Eddie Chen - MSFT On

There isn't any way to achieve this via extension manifest file. A good workaround is just as jessehouwing mentioned: Combine the two build tasks into one, provide an option in build setting to let user select or detect the build environment when running the build task. If TFS is selected or detected, run the code in the two build tasks, otherwise just run the code in the first build task.