如何使用内部版本号作为 INF 驱动程序版本的一部分

问题描述 投票:0回答:2

我是一个处理 INF 文件的初学者。 我的 .vcxproj 文件有一个属性,该属性使用 1.0.14.0 在 driverVer 中使用它。我的INF驱动程序版本如下 DriverVer=04/10/2024,10.0.14.0

我想在 INF 文件中使用内部版本号,例如 1.0.14.$(内部版本号)。

如何使用 azure 内部版本号来标记我的 INF 文件?

我尝试使用环境变量。但是,driverVer 不会选择内部版本号。

windows azure azure-devops inf windows-driver
2个回答
1
投票

根据您帖子的标签,我假设您的构建代理是基于 Windows 的。

您可以在管道中的“获取源”步骤之后使用 PowerShell 脚本任务来实现所需的结果。

你可以使用这个脚本:

# Get the build number from environment variable or build system
$buildNumber = $env:BUILD_BUILDNUMBER

# Path to driverVer.inf file (update this path if required
$infFilePath = "./driverVer.inf"

# Read the content of the file
$content = Get-Content -Path $infFilePath

# Define the regex pattern to capture only the final digit of the version number. Using capture groups
$pattern = '(DriverVer=\d+/\d+/\d+,\d+\.\d+\.\d+\.)(\d+)'

# Replace the final digit with the buildNumber using the regex pattern
$newContent = $content -replace $pattern, $1 + $buildNumber

# Write the updated content back to the file
Set-Content -Path $infFilePath -Value $newContent

0
投票

您可以使用 替换令牌任务 将 DriverVer 替换为 Azure DevOps 管道中的内部版本号。

我的测试步骤:

  1. 将扩展安装到组织。
  2. 使用存储库中 driverVer.inf 中的
    #{Build.BuildNumber}#
    模式:
[Version]
DriverVer=1.0.14.#{Build.BuildNumber}#
  1. 使用以下 yaml 自定义内部版本号。这是为了使变量
    $(Build.BuildNumber)
    仅包含单个版本号,而不是默认的日期+版本号。然后使用替换令牌任务将
    #{Build.BuildNumber}#
    替换为 inf 文件中的实际内部版本号。
trigger:
- none

pool:
  vmImage: windows-latest

name: $(Rev:r)

steps:
- script: echo '$(Build.BuildNumber)' # outputs customized build number

- task: replacetokens@6
  inputs:
    sources: '*.inf'
  1. 当内部版本号为 7 时,替换后的 driverVer.inf 如下所示。
[Version]
DriverVer=1.0.14.7
© www.soinside.com 2019 - 2024. All rights reserved.