Fix invalid version number issue in Azure Pipelines NuGet package publishing #323
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Azure Pipelines build was producing NuGet packages with version 1.0.0 instead of the configured version 9.2.0 defined in the pipeline variables. This occurred because the project file lacked an explicit
Version
property, causing .NET to default to 1.0.0 despite the pipeline attempting to override it.Root Cause
The
Xunit.Microsoft.DependencyInjection.csproj
file had no explicit version configuration, sodotnet pack
defaulted to version 1.0.0. While the Azure Pipeline used/p:PackageVersion=$(Major).$(Minor).$(Revision)
to override this, the approach was unreliable.Solution
Added explicit Version property to .csproj:
This ensures local builds produce version 9.2.0 instead of 1.0.0.
Updated Azure Pipeline for reliability: Changed from
/p:PackageVersion=
to/p:Version=
for more consistent version override behavior.Testing
Xunit.Microsoft.DependencyInjection.9.2.0.nupkg
/p:Version=9.3.0
produces correct 9.3.0 packageThis fix ensures that both local development builds and CI/CD pipeline builds produce packages with the correct version number, eliminating the issue where 1.0.0 packages were being published to NuGet.org.
Fixes #322.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.