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

How to create a custom release task that executes a console application with arguments

我一直盯着这里的教程并尝试了一段时间,但我就是想不出一个解决方案.. 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)"
        }
    }
}

可以参考vsts-task的源码CmdLine or AzurePowerShell任务:

{
    "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."
},