MaPi
MaPi

Reputation: 1601

Force a specific version param when packing a nuget in TFS build

I'm trying to setup a TFS build to publish a nuget version using a different version than the one specified by the build number (I use a string for the build definition name in the build number format and would like to keep it this way).

I'm passing -version $(MajorVersion).$(MinorVersion).$(Year:yy)$(DayOfYear).$(Rev:rr) to the Packager step, but it fails with this message:

Attempting to build package from 'MyProj.Contracts.nuspec'.

[error]'$(MajorVersion).$(MinorVersion).$(Year:yy)$(DayOfYear).$(Rev:rr)' is not a valid version string.
[error]Parameter name: version
[error]Unexpected exit code 1 returned from tool NuGet.exe

How can I make this work?

Upvotes: 1

Views: 153

Answers (1)

jessehouwing
jessehouwing

Reputation: 115027

Those version strings are not available in the build itself as variables. But if you've made them part of the Build.BuildNumber value, you can extract the version part from it using a bit of powershell or using my VSTS Variable Toolbox:

enter image description here

Then use that $(Nuget.VersionNumber) for your Nuget package task.

Upvotes: 0

Related Questions