我想在C#中整理一些VSTS构建/发布管理扩展,虽然我可以使用PowerShell找到一些通用示例,但在C#中使用一些示例会很方便。
有人能指点我的C#VSTS扩展示例吗?
答案 0 :(得分:2)
看看GitVersion的来源。作者编写了与之相关的TFS / VSTS任务。该工具的核心是纯C#。
这里是他们TFS任务的代码 https://github.com/GitTools/GitVersion/tree/master/src/GitVersionTfsTask
以下是您在构建中使用的任务 https://marketplace.visualstudio.com/items?itemName=gittools.gitversion#overview
答案 1 :(得分:2)
关于构建任务扩展,您可以指定C#应用程序,例如控制台应用程序:
import java.util.*;
public class Assignment3 {
static int Highernum;
static int Lowernum;
static String Response;
static int High;
static int Low;
static int Number;
static int random;
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
Random rand = new Random();
Boolean play = true;
while (play) {
System.out.println("Set the lowest number boundary:");
Low = console.nextInt();
System.out.println("Set the highest number boundary:");
High = console.nextInt();
System.out.println("So your number is between " + Low + " and " +
High);
Number = number(Low, High);
System.out.println("Computer: " + Number);
System.out.println("Is this your number?
(H)igher/(L)ower/(C)orrect");
Response = console.next();
Highernum = number(Number, High);
Lowernum = number(Low, Number);
while (Response.equalsIgnoreCase("H")) {
Highernum = number(Number, High);
Conditioncheck(console, Highernum);
while (Response.equalsIgnoreCase("L")) {
Lowernum = number(Low, Number);
Conditioncheck(console, Lowernum);
} if (Response.equalsIgnoreCase("C")) {
System.out.println("Play again?(Y/N)");
String Answer = console.next();
if (Answer.equalsIgnoreCase("N")) {
play = false;
} else {
play = true;
}
}
}
}
}
public static void Conditioncheck (Scanner console, int random) {
System.out.println("Computer: " + random);
System.out.println("Is this your number?
(H)igher/(L)ower/(C)orrect");
Response = console.next();
}
public static int number (int Low, int High) {
Random rand = new Random();
int randomNum = rand.nextInt((High - Low) + 1) + Low;
return randomNum;
}
public static Boolean check (Scanner console, Boolean play) {
System.out.println("Play again?(Y/N)");
String Answer = console.next();
if (Answer.equalsIgnoreCase("N")) {
play = false;
} else {
play = true;
}
return play;
}
然而Task SDK是Typescript和PowerShell,所以你不能直接在你的应用程序中使用SDK,最新的架构也删除了额外的架构信息(检查remove extra schema info #308),所以NodeJS和PowerShell是推荐的方式。