I have a Azure DevOps pipeline with a local nuget package to a local artifact repo, and then a push to nuget.org.
It however is not updating the version and remains at 1.0.0-{build_ver}
in the local azure DevOps project artifacts (whilst version is stuck the build_ver of the package
increments as expected), but when it tries to push to nutget it fails as its the same 1.0.0
version and ignores the 1.0.1
in the project file.
Any pointers please - how can i get the version defined in the csproj used in the build?
I have the folowing build yaml:
trigger:
- master
stages:
- stage: 'Build'
variables:
buildConfiguration: 'Release'
jobs:
- job:
pool:
vmImage: 'ubuntu-latest'
workspace:
clean: all
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 2.2.x
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
displayName: "NuGet Restore"
inputs:
command: restore
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
displayName: "Build Solution"
inputs:
command: build
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: "Test Solution"
inputs:
command: test
projects: '**/*Test/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'Create NuGet Package - Release Version'
inputs:
command: pack
packDirectory: '$(Build.ArtifactStagingDirectory)/packages/releases'
arguments: '--configuration $(buildConfiguration)'
nobuild: true
- task: DotNetCoreCLI@2
displayName: 'Create NuGet Package - Prerelease Version'
inputs:
command: pack
buildProperties: 'VersionSuffix="$(Build.BuildNumber)"'
packDirectory: '$(Build.ArtifactStagingDirectory)/packages/prereleases'
arguments: '--configuration $(buildConfiguration)'
- publish: '$(Build.ArtifactStagingDirectory)/packages'
artifact: 'packages'
- stage: 'PublishPrereleaseNuGetPackage'
displayName: 'Publish Prerelease NuGet Package'
dependsOn: 'Build'
condition: succeeded()
jobs:
- job:
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: none
- download: current
artifact: 'packages'
- task: NuGetCommand@2
displayName: 'Push NuGet Package'
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/packages/prereleases/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'Unified.Mqtt.Pattern/Unified.Mqtt.Pattern-Test'
- stage: 'PublishReleaseNuGetPackage'
displayName: 'Publish Release NuGet Package'
dependsOn: 'PublishPrereleaseNuGetPackage'
condition: succeeded()
jobs:
- deployment:
pool:
vmImage: 'ubuntu-latest'
environment: 'nuget-org'
strategy:
runOnce:
deploy:
steps:
- task: NuGetCommand@2
displayName: 'Push NuGet Package'
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/packages/releases/*.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'NuGet Unified.Mqtt.Pattern'
My csproj
has the following:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Authors>Christopher Morley</Authors>
<Company>Unified Microsystems</Company>
<Copyright />
<PackageId>Unified.Mqtt.Pattern</PackageId>
<Description>C# port of RangerMauve's mqtt-pattern fast library for matching MQTT patterns with named wildcards to extract data from topics.</Description>
<RepositoryUrl>https://github.com/unifiedmicrosystems/Unified.Mqtt.Pattern</RepositoryUrl>
<PackageProjectUrl>https://github.com/unifiedmicrosystems/Unified.Mqtt.Pattern</PackageProjectUrl>
<RepositoryType>github.com</RepositoryType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageIconUrl>https://www.unifiedmicro.systems/resources/unified-logo.png</PackageIconUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\LICENSE">
<Pack>True</Pack>
<PackagePath></PackagePath>
<VersionPrefix>1.0.1</VersionPrefix>
</None>
</ItemGroup>
</Project>