欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android開發(fā)vsts?agent支持自定義task過程詳解

 更新時間:2022年04月02日 10:28:34   作者:重典  
這篇文章主要介紹了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.json

extract-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的詳細(xì)內(nèi)容,更多關(guān)于vsts agent的task的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評論