Thi*_*ara 9 nuget azure-devops azure-pipelines-build-task azure-pipelines
我使用下面的 yaml 来生成我的 NuGet pkg。我想为我的包裹提供一个带有日期的唯一 ID。但我不断收到错误消息,说在以下环境变量中找不到版本号数据:BUILD_BUILDNUMBER
##[错误]在以下环境变量中找不到版本号数据:BUILD_BUILDNUMBER。变量的值应包含一个带有或为正整数的子字符串。
我尝试使用 name: $(Build.DefinitionName)-$(date:yyyyMMdd)$(rev:.r)# 需要这个用于byBuildNumberverisonScheme nuget 包。
还尝试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
Run Code Online (Sandbox Code Playgroud)
我希望它生成具有正确版本号的 nuget,而不会在 nuget pack 步骤中失败。
Sha*_*zyk 10
当您选择 NuGet 包版本时,您无法将此值$(Build.DefinitionName)-$(date:yyyyMMdd)$(rev:.r)赋予内部版本号。
它应该是这种格式:
$(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r).
您可以在经典编辑器中看到此信息:
您可以在文档中找到更多信息:
对于byPrereleaseNumber,版本将设置为您为主要、次要和补丁选择的任何内容,加上格式为 yyyymmdd-hhmmss 的日期和时间。
对于byEnvVar,版本将被设置为您提供的任何环境变量,例如 MyVersion(没有 $,只是环境变量名称)。确保环境变量设置为适当的 SemVer,例如 1.2.3 或 1.2.3-beta1。
对于byBuildNumber,版本将设置为内部版本号,确保您的内部版本号是正确的 SemVer,例如 1.0.$(Rev:r)。如果您选择 byBuildNumber,该任务将提取带点的版本 1.2.3.4 并仅使用该版本,删除任何标签。要按原样使用内部版本号,您应该如上所述使用 byEnvVar,并将环境变量设置为 BUILD_BUILDNUMBER。
| 归档时间: |
|
| 查看次数: |
3760 次 |
| 最近记录: |