Android開發(fā)vsts?agent支持自定義task過程詳解
vsts 中支持自定義Build/Release的過程Task
目標(biāo):做一個可以讀取 Xamarin.Android 所生成的 APK 的 基本信息的 task ,包括 package(包名) / application label(應(yīng)用標(biāo)題 )/version name(版本號)/version code(版本代碼)
下面簡述流程

1.下載并安裝 Visual Studio Code(http://code.visualstudio.com ),當(dāng)然使用 Visual Studio 或者其它任何開發(fā)工具也可以
2.下載并安裝最新版本 nodejs(https://nodejs.org),如果是直接安裝的 vs 這些應(yīng)該直接都有了
3.建立自己的項目文件夾,如 d:\code\home
4.通過 npm 安裝編譯工具 tfx-cli
npm i -g tfx-cli
5.在自己的項目文件夾中建立一個 vss-extension.json 文件,這個文件中說明了當(dāng)前擴展包的信息,以及擴展包中包含哪些任務(wù)
{
"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.以上面擴展信息中所示,擴展包中包含了一個叫 extract-xamarin-android-manifest(我的任務(wù)) 的插件,文件夾結(jié)構(gòu)是這樣的
extension-icon.png (vsix的圖標(biāo))
vss-extension.jsonextract-xamarin-android-manifest
- extract.ps1 (任務(wù)的對應(yīng)腳本,是在task.json中配置的此名稱)
- icon.png (任務(wù)的圖標(biāo))
- task.json (任務(wù)的配置文件)
其中 task.json 是最主要的文件,我當(dāng)前的這個擴展是讀取 Xamarin.Android 的項目,并且讀取出生成 apk 的基礎(chǔ)信息,包含 application 的 label,packagename,version name,version code
{
"id": "f1821fab-78d1-4c22-a0e4-f98f40fd7079",//任務(wù)的唯一id
"name": "extract-xamarin-android-manifest",//任務(wù)名稱
"friendlyName": "extract xamarin android info",//友好任務(wù)名
"description": "extract xamarin android info",
"author": "zoujian",
"helpMarkDown": "[More Information](https://github.com/chsword/zou-vsts-tasks)",//幫助(就是顯示時后面的吧號)
"category": "Utility",//類別,工具
"visibility": [
"Build",
"Release"
],
"demands": [
"DotNetFramework"
],
"version": {//版本
"Major": "1",
"Minor": "0",
"Patch": "4"
},
"minimumAgentVersion": "1.83.0",//支持vso agent的版本
"instanceNameFormat": "ExtractXamarinAndroidManifest",//實例名
"groups": [//如果輸入?yún)?shù)要分組的話,建一個
{
"name": "output",
"displayName": "Output",
"isExpanded": true
}
],
"inputs": [//各種輸入?yún)?shù)
{
"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, will return 'android.PackageName','android.ApplicationLabel','android.VersionName','android.VersionCode'."
}
],
"execution": {//實際執(zhí)行的過程,我這里是執(zhí)行了一個powershell腳本,有興趣的同學(xué)可以看下,就是讀取了apk的AndroidManifest的xml結(jié)構(gòu)
"PowerShell": {
"target": "$(currentDirectory)\\extract.ps1",
"argumentFormat": "",
"workingDirectory": "$(currentDirectory)"
}
}
}7.要編譯為VSIX的話,執(zhí)行 tfx extension create --manifest-globs vss-extension.json
8.tfs或vso中導(dǎo)入vsix,過程不說述
9.可以直接在tfs中使用了
實際使用時,如此配置參數(shù):

源代碼:https://github.com/chsword/zou-vsts-tasks
引用 :
官方task:https://github.com/Microsoft/vsts-tasks
官方文檔:https://www.visualstudio.com/zh-cn/docs/build/define/variables
以上就是開發(fā)一個 vsts agent 的 task的詳細內(nèi)容,更多關(guān)于vsts agent的task的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Androd 勇闖高階性能優(yōu)化之布局優(yōu)化篇
Android性能優(yōu)化方面也有很多文章了,這里就做一個總結(jié),從原理到方法,工具等做一個簡單的了解,從而可以慢慢地改變編碼風(fēng)格,從而提高性能2021-10-10
Android從0到完整項目(1)使用Android studio 創(chuàng)建項目詳解
本篇文章主要介紹了Android從0到完整項目(1)使用Android studio 創(chuàng)建項目詳解,具有一定的參考價值,有興趣的可以了解一下2017-07-07
Android 使用SharedPreferrences儲存密碼登錄界面記住密碼功能
Android存儲方式有很多種,在這里所用的存儲方式是SharedPreferrences, 其采用了Map數(shù)據(jù)結(jié)構(gòu)來存儲數(shù)據(jù),以鍵值的方式存儲,可以簡單的讀取與寫入,下面通過實例代碼給大家講解下,需要的朋友參考下吧2017-04-04
Android中Android Virtual Device(AVD)使用教程
這篇文章主要介紹了Android中Android Virtual Device(AVD)使用教程,本文還對使用過程中發(fā)生的一些錯誤給出了處理方法,需要的朋友可以參考下2015-01-01
Android程序開發(fā)之使用PullToRefresh實現(xiàn)下拉刷新和上拉加載
這篇文章主要介紹了Android程序開發(fā)之使用PullToRefresh實現(xiàn)下拉刷新和上拉加載的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-07-07
Android ViewPager實現(xiàn)無限循環(huán)效果
這篇文章主要為大家詳細介紹了Android ViewPager實現(xiàn)無限循環(huán)效果的相關(guān)資料,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-03-03

