Currently my build produces both packages having a newer version every time:
Release: Automatic package versioning = Use the build number
Pre-release: Additional build properties = Version=$(user.BuildFullVersion)-beta
And the only one nuspec has a placeholder to version:
<version>$version$</version>
I want to increment version manually, that it - repetitive build would produce same version until I increment it manually.
How can I achieve that still having single nuspec?
Can I adjust package version in the pack tasks like this:
Release: $(PackageVersion) = $(PackageVersion)
Pre-release: $(PackageVersion) = $(PackageVersion)-beta
Or something similar.
To produce two packages by a nuspec, you can use two NuGet tasks (NuGet custom instead NuGet pack):
NuGet task:
Command: custom
Command and arguments:
pack $(Build.SourcesDirectory)\Package.nuspec -Version $(Build.BuildNumber) -OutputDirectory $(build.artifactstagingdirectory)
NuGet task:
Command: custom
Command and arguments:
pack $(Build.SourcesDirectory)\Package.nuspec -Version $(Build.BuildNumber) -Suffix beta -OutputDirectory $(build.artifactstagingdirectory)
If you set the $(Build.BuildNumber)
as the format like MyProject-Daily_1.0.94.0
while you want to add the version for nuget package as 1.0.94.0
, you can define a variable in your build definition and set the value by cutting the substring of $(Build.BuildNumber)
. detail steps as below:
In Variables Tab, add a variable (such as version
) with any value (such as temp
).
Add a PowerShell Task before NuGet tasks with the settings,
Type: Inline Script
Inline Script:
$s1=$(Build.BuildNumber).split('_')[1].split(' ')
Write-Host "##vso[task.setvariable variable=version]$s1"
Then in the NuGet Custom tasks use $(version)
to replace $(Build.BuildNumber)
for -version
option. Such as nuget pack -version $(version)
.