microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.47k stars 2.6k forks source link

NuGetPackager task stripping suffix from build number #3832

Closed dsteinweg closed 7 years ago

dsteinweg commented 7 years ago

We're using TFS2017 Update 1, and we have a build that has a suffix on the build number, e.g. "1.0.0-dev". We want that exact build number to be used in the NuGetPackager task, thus NuGet would consider it a "prerelease" package because it detects an arbitrary suffix. We have "Automatic package versioning" set to "Use the build number".

However, it seems like the NuGetPackager task script is stripping off this suffix, so even though our build number ends with "-dev", the NuGet package version does not, and thus is not a prerelease package. The script seems to be doing some regex work to pull out the number values from the build number string: https://github.com/Microsoft/vsts-tasks/blob/master/Tasks/NugetPackager/NuGetPackager.ps1#L75

We have version 0.1.72 of the NuGetPackager task, and the contents of the .ps1 file on our agents exactly matches which I linked above.

Is this stripping of the suffix intentional?

For now, our workaround is to set "Automatic package versioning" to "Off", and then explicitly setting the package version by setting "NuGet Arguments" to "-Version $(Build.BuildNumber)", which properly preserves the suffix and generates a prerelease package.

infin8x commented 7 years ago

It is intentional right now. Your workaround is the right way to go for now. We plan to do some wide-ranging improvements to the automatic versioning logic in a future sprint.

janpieterz commented 6 years ago

@alexmullans looks like this is still happening, was surprised to see I suddenly released a final release versioned package that wasn't actually a valid final release.

Any idea when this sprint with the wide-ranging improvements would happen?

infin8x commented 6 years ago

Sorry about that.

It's not currently scheduled, but it remains on the backlog.

cravecode commented 3 years ago

@dsteinweg, thanks for posting this. I thought i was going crazy. This still exists in the new DotNetCoreCli pack command. https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/DotNetCoreCLIV2/packcommand.ts#L64

For those looking for assistance with their YAML build files; here is my pack step:

- task: DotNetCoreCLI@2
  inputs:
    command: 'pack'
    packagesToPack: '**/*.csproj'
    includesymbols: true
    versioningScheme: 'off'
    buildProperties: 'SymbolPackageFormat=snupkg;PackageVersion=$(Build.BuildNumber)'
sec commented 1 year ago

Thanks for the workaround. Sad to see, this wasn't fixed in 6 year time...