Azure Pipelines - 尽管预发布任务不是 运行,但包正在使用预发布任务的版本控制而不是发布任务
Azure Pipelines - Packages are using versioning from pre-release task rather than release task despite pre-release task not running
基本上,我有一个将包推送到提要的管道。如果源是 development
分支,我将它设置为使用环境变量来创建预发布包版本。否则,如果源分支是 master
,它应该从 .csproj
文件中读取版本控制。根据日志,正确的步骤是 运行。然而,当我到达 push
步骤时,我注意到在日志中它正在推送预发布而不是发布到提要,尽管预发布任务甚至没有 运行。这是怎么回事,我该如何解决?以下是相关任务:
variables:
buildConfiguration: 'Release'
isDev: $[eq(variables['Build.SourceBranch'], 'refs/heads/development')]
isMain: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
- task: DotNetCoreCLI@2
displayName: "Dotnet Pack"
condition: eq(variables.isMain, true)
inputs:
command: 'pack'
arguments: '--configuration $(buildConfiguration)'
packagesToPack: '**/*.csproj'
nobuild: true
versioningScheme: 'off'
- task: DotNetCoreCLI@2
displayName: "Dotnet Pack (pre-release)"
condition: eq(variables.isDev, true)
inputs:
command: 'pack'
arguments: '--configuration $(buildConfiguration)'
packagesToPack: '**/*.csproj'
nobuild: true
versioningScheme: byEnvVar
versionEnvVar: PackageVersion
- task: NuGetCommand@2
displayName: 'Nuget Push to Feed'
inputs:
command: 'push'
feedsToUse: 'select'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: '*cleared*'
versioningScheme: 'off'
allowPackageConflicts: true
when I get to the push step, I notice in the logs that it's pushing a pre-release rather than the release to the feed despite the pre-release task not even running.
根据我的测试,当我 运行 使用您的 Yaml 管道示例的管道时,我可以重现这个问题。
此问题的根本原因是环境变量的名称 PackageVersion。
当环境变量名为PackageVersion时,会存在该问题
要解决此问题,您可以更改环境变量名称。
- task: DotNetCoreCLI@2
displayName: "Dotnet Pack (pre-release)"
condition: eq(variables.isDev, true)
inputs:
command: 'pack'
arguments: '--configuration $(buildConfiguration)'
packagesToPack: '**/*.csproj'
nobuild: true
versioningScheme: byEnvVar
versionEnvVar: Package1
然后就可以正常工作了。
基本上,我有一个将包推送到提要的管道。如果源是 development
分支,我将它设置为使用环境变量来创建预发布包版本。否则,如果源分支是 master
,它应该从 .csproj
文件中读取版本控制。根据日志,正确的步骤是 运行。然而,当我到达 push
步骤时,我注意到在日志中它正在推送预发布而不是发布到提要,尽管预发布任务甚至没有 运行。这是怎么回事,我该如何解决?以下是相关任务:
variables:
buildConfiguration: 'Release'
isDev: $[eq(variables['Build.SourceBranch'], 'refs/heads/development')]
isMain: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
- task: DotNetCoreCLI@2
displayName: "Dotnet Pack"
condition: eq(variables.isMain, true)
inputs:
command: 'pack'
arguments: '--configuration $(buildConfiguration)'
packagesToPack: '**/*.csproj'
nobuild: true
versioningScheme: 'off'
- task: DotNetCoreCLI@2
displayName: "Dotnet Pack (pre-release)"
condition: eq(variables.isDev, true)
inputs:
command: 'pack'
arguments: '--configuration $(buildConfiguration)'
packagesToPack: '**/*.csproj'
nobuild: true
versioningScheme: byEnvVar
versionEnvVar: PackageVersion
- task: NuGetCommand@2
displayName: 'Nuget Push to Feed'
inputs:
command: 'push'
feedsToUse: 'select'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: '*cleared*'
versioningScheme: 'off'
allowPackageConflicts: true
when I get to the push step, I notice in the logs that it's pushing a pre-release rather than the release to the feed despite the pre-release task not even running.
根据我的测试,当我 运行 使用您的 Yaml 管道示例的管道时,我可以重现这个问题。
此问题的根本原因是环境变量的名称 PackageVersion。
当环境变量名为PackageVersion时,会存在该问题
要解决此问题,您可以更改环境变量名称。
- task: DotNetCoreCLI@2
displayName: "Dotnet Pack (pre-release)"
condition: eq(variables.isDev, true)
inputs:
command: 'pack'
arguments: '--configuration $(buildConfiguration)'
packagesToPack: '**/*.csproj'
nobuild: true
versioningScheme: byEnvVar
versionEnvVar: Package1
然后就可以正常工作了。