Develop a task for the VSTS agent yourself

Source: Internet
Author: User

Process tasks in VSTS that support custom build/release

Objective: To do a task that can read the basic information of the APK generated by xamarin.android, including the package name/Application label (app title)/version name (version number)/version code (Version code)

The process is outlined below

1. Download and install Visual Studio Code (http://code.visualstudio.com), and of course use Visual Studio or any other development tool to

2. Download and install the latest version of Nodejs (https://nodejs.org), if it is directly installed vs these should be directly available

3. Create your own project folder, such as D:\code\home

4. Install the build tool via NPM TFX-CLI

NPM i-g TFX-CLI

5. Create a vss-extension.json file in your project folder that describes the current expansion pack information and which tasks are included in the extension package

{    "manifestversion":1,    "ID":"Zou-tasks",    "name":"Zou Tasks",    "version":"1.0.4",    "Publisher":"Zoujian",    "Targets": [        {            "ID":"Microsoft.VisualStudio.Services"        }    ],    "Description":"Tools for building & Publish",    "Categories": [        "Build and Release"    ],    "icons": {        "default":"Extension-icon.png"    },    "Files": [        {            "Path":"extract-xamarin-android-manifest"        }    ],    "Contributions": [        {            "ID":"extract-xamarin-android-manifest",            "type":"Ms.vss-distributed-task.task",            "Targets": [                "Ms.vss-distributed-task.tasks"            ],            "Properties": {                "name":"extract-xamarin-android-manifest"            }        }    ]}

6. As shown in the extension information above, the expansion pack contains a plugin called extract-xamarin-android-manifest (my Task), the folder structure is like this


Extension-icon.png (VSIX's icon)
Vss-extension.json

Extract-xamarin-android-manifest
-EXTRACT.PS1 (the corresponding script for the task, which is the name configured in Task.json)
-Icon.png (Icon of Task)
-Task.json (Task profile)

Where Task.json is the most important file, my current extension is to read the Xamarin.android project and read the basic information that was born into the APK, including the application label,packagename,version name, Version Code

{  "id": "f1821fab-78d1-4c22-a0e4-f98f40fd7079",//Unique ID of the task"Name": "Extract-xamarin-android-manifest",//Task name"FriendlyName": "Extract Xamarin Android Info",//Friendly task name"description": "Extract Xamarin Android Info",  "Author": "Zoujian",  "Helpmarkdown": "[More information] (https://github.com/chsword/zou-vsts-tasks)",//help (that is, the bar number after display)"category": "Utility",//categories, tools"Visibility": [    "Build",    "Release"  ],  "Demands": [    "dotNetFramework"  ],  "Version": {//version"Major": "1",    "Minor": "0",    "Patch": "4"  },  "Minimumagentversion": "1.83.0",//support for VSO agent version"Instancenameformat": "Extractxamarinandroidmanifest",//instance name"Groups": [//If input parameters are to be grouped, create a {"Name": "Output",      "DisplayName": "Output",      "IsExpanded":true    }  ],  "Inputs": [//Various input parameters {"Name": "Pathxamarinandroidproject",      "Type": "FilePath",      "Label": "Xamarin Android Project Path",      "DefaultValue": "",      "Required":true,      "Helpmarkdown": "Path which Xamarin Android project exisis."    },    {      "Name": "Configuration",      ' Type ': ' String ',      "Label": "Configuration",      "DefaultValue": "$ (buildconfiguration)",      "Required":true    },    {      "Name": "Outputvariable",      ' Type ': ' String ',      "Label": "Outputvariable",      "Required":true,      "DefaultValue": "Android",      "GroupName": "Output",      "Helpmarkdown": "Provide a name for the variable for the Android info. eg. Set the Outputvariable ' Android ', after task running, 'll return ' Android. PackageName ', ' Android. Applicationlabel ', ' Android. Versionname ', ' Android. Versioncode '. "    }  ],  "Execution": {//actual execution of the process, I am here to execute a PowerShell script, interested classmates can look at, is read the APK androidmanifest XML Structure"PowerShell": {      "Target": "$ (currentdirectory) \\extract.ps1",      "Argumentformat": "",      "WorkingDirectory": "$ (currentdirectory)"    }  }}

7. To compile to VSIX, execute TFX extension Create--manifest-globs Vss-extension.json

8.tfs or VSO Import VSIX, procedure does not say

9. You can use it directly in TFS

When actually used, this configuration parameter:

Source code: Https://github.com/chsword/zou-vsts-tasks

Reference:

Official Task:https://github.com/microsoft/vsts-tasks

Official Document: Https://www.visualstudio.com/zh-cn/docs/build/define/variables

Develop a task for the VSTS agent yourself

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.