mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-18 21:21:17 +00:00
### Description BUG FIX: the if...else in telemetry-steps.yml does not really work. It always says "Telemetry is disabled." even through the pipeline doesn't have the pipeline variable. ### Motivation and Context For example, recently I setup a new pipeline in https://dev.azure.com/onnxruntime/onnxruntime/_build without setting the ADO variable, but the powershell code still thinks that we have enabled telemetry. See: https://dev.azure.com/onnxruntime/onnxruntime/_build/results?buildId=910107&view=results The reason it didn't work because when the pipeline variable("TELEMETRYGUID") doesn't exist, the occurrence of "$(TELEMETRYGUID)" would be not replace to anything. It will remain as it is.
15 lines
No EOL
1.1 KiB
PowerShell
15 lines
No EOL
1.1 KiB
PowerShell
# The first part of the expression in the following "if" statement is necessary, otherwise it will report an error,
|
|
# "You cannot call a method on a null-valued expression.", when the env variable does not exist.
|
|
if (-not [string]::IsNullOrEmpty( $Env:TELEMETRYGUID) -and $Env:TELEMETRYGUID.StartsWith('"')) {
|
|
$length = $Env:TELEMETRYGUID.length
|
|
# See https://learn.microsoft.com/en-us/windows/win32/api/traceloggingprovider/nf-traceloggingprovider-traceloggingoptiongroup
|
|
# The value of the env variable must have quotes, because we do not add the quotes here.
|
|
$fileContent = "#define TraceLoggingOptionMicrosoftTelemetry() \
|
|
TraceLoggingOptionGroup("+$Env:TELEMETRYGUID.substring(1, $length-2)+")"
|
|
New-Item -Path "include\onnxruntime\core\platform\windows\TraceLoggingConfigPrivate.h" -ItemType "file" -Value "$fileContent" -Force
|
|
Write-Host "##vso[task.setvariable variable=TelemetryOption]--use_telemetry"
|
|
Write-Host "Telemetry is enabled."
|
|
} else {
|
|
Write-Host "##vso[task.setvariable variable=TelemetryOption]"
|
|
Write-Host "Telemetry is disabled."
|
|
} |