在 Azure DevOps 管道模板中,我将参数声明为数组/序列
parameters:
mySubscription: ''
myArray: []
steps:
- AzureCLI@2
inputs:
azureSubscription: ${{ parameters.mySubscription }}
scriptType: pscore
scriptPath: $(Build.SourcesDirectory)/script.ps1
arguments: '-MyYAMLArgument ${{ parameters.myArray }}'
Run Code Online (Sandbox Code Playgroud)
然后从管道定义传递参数的值作为
steps:
- template: myTemplate.yml
parameters:
mySubscription: 'azure-connection'
myArray:
- field1: 'a'
field2: 'b'
- field1: 'aa'
field2: 'bb'
Run Code Online (Sandbox Code Playgroud)
我的问题是我无法在 YAML 语法(某种ToString()
)中按原样传递该数组,以便能够在我的模板中从 PowerShell 使用和处理该数组。尝试运行此管道时,出现以下错误:
/myTemplate.yml (Line: X, Col: X): Unable to convert from Array to String. Value: Array
. 错误消息中引用的行/列对应arguments: '-MyYAMLArgument ${{ parameters.myArray }}'
于我的模板。
我还尝试将参数映射为脚本的环境
- AzureCLI@2
inputs:
azureSubscription: ${{ …
Run Code Online (Sandbox Code Playgroud) 根据文档https://docs.microsoft.com/en-us/nuget/schema/msbuild-targets,看起来 msbuild 现在支持 NuGet 的 2 个特定目标:Pack
和Restore
. 我已经能够Restore
正常使用,但不能Pack
。
错误 MSB4057:项目中不存在目标“Pack”。
它支持传统的 .Net 项目还是仅支持 .Net Core?
我一直找不到任何文件清楚地说明它。
关于所需的依赖项,我正在使用
PM> nuget help
NuGet Version: 4.1.0.2450
usage: NuGet <command> [args] [options]
Type 'NuGet help <command>' for help on a specific command.
Run Code Online (Sandbox Code Playgroud)
和
C:\Git>msbuild /version
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.
15.1.1012.6693
Run Code Online (Sandbox Code Playgroud)
和
Microsoft Visual Studio Professional 2017
Version 15.2 (26430.12) Release
VisualStudio.15.Release/15.2.0+26430.12
Microsoft .NET Framework
Version …
Run Code Online (Sandbox Code Playgroud)