如何创建自定义发布任务以执行带有参数的控制台应用程序

时间:2018-10-03 15:15:16

标签: azure-devops azure-pipelines azure-pipelines-release-pipeline azure-devops-extensions

我一直盯着这里看了一段时间的教程,但是我只是想不出一个解决方案。.https://docs.microsoft.com/en-us/azure/devops/extend/?view=vsts

我想创建一个自定义发行任务,该任务使用一些参数执行SomeImportTool.exe。

当前,我将命令行任务与以下

结合使用
Display name: 
    Run SomeImportTool
Tool:
    $(System.DefaultWorkingDirectory)/SomeImportTool/SomeImportTool.exe
Arguments:
    -f "$(XmlFile)" -c "$(ConnectionString)" -l "$(CultureCode)"

我如何创建基本上做到这一点的Task.json?

{
    "id": "{{taskguid}}",
    "name": "SomeImportTool",
    "friendlyName": "Run Some Resource Import Tool",
    "description": "Run Some Resource Import Tool",
    "helpMarkDown": "",
    "category": "Deploy",
    "visibility": [
        "Release"
    ],
    "author": "{{author}}",
    "version": {
        "Major": 0,
        "Minor": 1,
        "Patch": 0
    },
    "instanceNameFormat": "Echo $(SomeImportTool)",
    "groups": [
        {
            "name": "advanced",
            "displayName": "Advanced",
            "isExpanded": false
        }
    ],
    "inputs": [

        {
            "name": "XmlFile",
            "type": "string",
            "label": "XmlFile",
            "defaultValue": "",
            "required": true,
            "helpMarkDown": "File path to the resource file"
        },
        {
            "name": "CultureCode",
            "type": "string",
            "label": "Culture Code",
            "defaultValue": "",
            "required": true,
            "helpMarkDown": "culture code"
        },
        {
            "name": "ConnectionString",
            "type": "string",
            "label": "Connection String",
            "defaultValue": "",
            "required": true,
            "helpMarkDown": "Connection string"
        }
    ],
    "execution": {
        "PowerShell3":{
            "target": "someApplication.exe",
            "platforms":[
                "windows"
            ],
            "workingDirectory" : "$(currentDirectory)"
        }
    }
}

1 个答案:

答案 0 :(得分:1)

您可以引用vsts-task CmdLineAzurePowerShell任务的源代码:

{
    "name": "ScriptArguments",
    "type": "string",
    "label": "Script Arguments",
    "defaultValue": "",
    "visibleRule": "ScriptType = FilePath",
    "required": false,
    "properties": {
        "editorExtension": "ms.vss-services-azure.parameters-grid"
    },
    "helpMarkDown": "Additional parameters to pass to PowerShell.  Can be either ordinal or named parameters."
},