gpt4 book ai didi

azure-devops - ## [错误]在以下环境变量: BUILD_BUILDNUMBER中找不到版本号数据

转载 作者:行者123 更新时间:2023-12-03 16:15:34 25 4
gpt4 key购买 nike

我正在使用以下yaml生成我的NuGet pkg。我想为包裹添加唯一的ID和日期。但我不断收到错误消息,说无法在以下环境变量中找到版本号数据:BUILD_BUILDNUMBER

##[error]Could not find version number data in the following environment variable: BUILD_BUILDNUMBER. The value of the variable should contain a substring with or are positive integers.



我尝试使用名称: $(Build.DefinitionName)-$(date:yyyyMMdd)$(rev:.r)byBuildNumber verisonScheme nuget pack需要此名称。

还尝试将 BUILD_BUILDNUMBER设置为yaml文件中的变量。
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

name: $(Build.DefinitionName)-$(date:yyyyMMdd)$(rev:.r) # need this for byBuildNumber verisonScheme nuget pack
# the build will trigger on any changes to the master branch
trigger:
- master

# the build will run on a Microsoft hosted agent, using the lastest Windows VM Image
pool:
vmImage: 'windows-latest'

# these variables are available throughout the build file
# just the build configuration is defined, in this case we are building Release packages
variables:
buildConfiguration: 'Release'


#The build has 3 seperate tasks run under 1 step
steps:
# The first task is the dotnet command build, pointing to our csproj file
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
command: 'build'
arguments: '--configuration $(buildConfiguration)'
projects: 'src/Repository.sln'

# The second task is dotnet pack command again pointing to the csproj file
# The nobuild means the project will not be compiled before running pack, because its already built in above step
- task: DotNetCoreCLI@2
displayName: "dotnet pack"
inputs:
command: 'pack'
arguments: '--configuration $(buildConfiguration)'
packagesToPack: 'src/Common.Core/Common.Core.csproj'
nobuild: true
includeSymbols: true
versioningScheme: 'byBuildNumber'


# The last task is a nuget command, nuget push
# This will push any .nupkg files to the 'Nuget' artifact feed
# allowPackageConflicts allows us to build the same version and not throw an error when trying to push
# instead it just ingores the latest package unless the version changes
- task: NuGetCommand@2
displayName: 'nuget push'
inputs:
command: 'push'
feedsToUse: 'select'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'MyNuget'
allowPackageConflicts: true



我希望它会生成具有正确版本号的nuget,而不会导致nuget pack步骤失败。

最佳答案

当您选择NuGet软件包的版本将类似于内部版本号时,您不能将此值$(Build.DefinitionName)-$(date:yyyyMMdd)$(rev:.r)赋予内部版本号。

应采用以下格式:
$(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)

您可以在经典编辑器中看到此信息:

enter image description here

您可以在docs中找到更多信息:

对于 byPrereleaseNumber ,版本将设置为您为主要,次要和补丁选择的任何版本,以及日期和时间,格式为yyyymmdd-hhmmss。

对于EnvVar 的,版本将设置为任何环境变量,例如您提供的是MyVersion(没有$,只有环境变量名称)。确保将环境变量设置为适当的SemVer,例如1.2.3或1.2.3-beta1。

对于 byBuildNumber ,版本将设置为内部版本号,请确保您的内部版本号是正确的SemVer例如。 1.0。$(Rev:r)。如果选择byBuildNumber,则该任务将提取一个带点缀的版本1.2.3.4,并仅使用该版本,并删除所有标签。要按原样使用内部版本号,您应该如上所述使用byEnvVar,并将环境变量设置为BUILD_BUILDNUMBER。

关于azure-devops - ## [错误]在以下环境变量: BUILD_BUILDNUMBER中找不到版本号数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57797140/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com