onnxruntime/tools/ci_build/github/azure-pipelines/nuget/templates/get-nuget-package-version-as-variable.yml
Edward Chen 6d46007028
Add explicit 'set +x' before printing a vso[] command to avoid output getting parsed again with a trailing quote. (#15986)
Here's the motivating issue:
https://github.com/microsoft/azure-pipelines-tasks/issues/10331

Noticed some problems in other repos so also updating usages in ORT.

We may be fine now without it, but this change adds some safeguard against future additions of 'set -x' for debugging.
2023-05-17 19:30:28 -07:00

42 lines
1.7 KiB
YAML

parameters:
packageFolder: $(Build.ArtifactStagingDirectory)
steps:
- task: CmdLine@2
condition: eq(variables['Agent.OS'], 'Windows_NT')
displayName: 'Extract version number from the NuPkg file, Windows VMs'
inputs:
workingDirectory: '${{ parameters.packageFolder }}'
script: |
SETLOCAL EnableDelayedExpansion
FOR /R %%i IN (Microsoft.ML.OnnxRuntime.Managed*.nupkg) do (
set filename=%%~ni
set ortversion=!filename:~33!
@echo ortversion is !ortversion!
@echo ##vso[task.setvariable variable=NuGetPackageVersionNumber;]!ortversion!
)
- task: CmdLine@2
condition: eq(variables['Agent.OS'], 'Windows_NT')
displayName: 'Extract version number from the DirectML NuPkg file, Windows VMs'
inputs:
workingDirectory: '${{ parameters.packageFolder }}'
script: |
SETLOCAL EnableDelayedExpansion
FOR /R %%i IN (Microsoft.ML.OnnxRuntime.DirectML*.nupkg) do (
set filename=%%~ni
set ortversion=!filename:~34!
@echo DirectMLNuGetPackageVersionNumber is !ortversion!
@echo ##vso[task.setvariable variable=DirectMLNuGetPackageVersionNumber;]!ortversion!
)
- task: CmdLine@2
condition: not(eq(variables['Agent.OS'], 'Windows_NT'))
displayName: 'Extract version number from the NuPkg file, Unix VMs'
inputs:
workingDirectory: '${{ parameters.packageFolder }}'
script: |
filenamewithext=$(ls Microsoft.ML.OnnxRuntime.Managed*nupkg)
filename=${filenamewithext%.*}
ortversion=${filename:33}
# Do not output ##vso[] commands with `set -x` or they may be parsed again and include a trailing quote.
set +x
echo "##vso[task.setvariable variable=NuGetPackageVersionNumber;]$ortversion"