Update nuget version regex
📙 What does this MR do and why?
This MR updates the NuGet package version regex to allow for short versions containing only the major
and minor
components of a semantic version, for example 1.0
.
The regex that validates the version for NuGet packages currently requires a minimum of major.minor.patch
(semantic versioning). Users have identified that it is not uncommon for NuGet packages to break from this norm and use extended or short versions such as 1.0
or 1.0.0.0
.
📼 Screenshots or screen recordings
🗒 How to set up and validate locally
The NuGet and dotnet CLI tools unfortunately do not allow short versions. I did not check using visual studio, but we can manually edit the version before publishing the package.
- Ensure you have the NuGet CLI installed (see nuget docs for links to installation pages).
- In a new directory, run
nuget spec
. - Update version in the
Package.nuspec
to be0.1
. - Run
nuget pack
to generate aPackage.0.1.0.nupkg
file. - Notice the NuGet CLI automatically updated the version to
0.1.0
, we need to update the version manually:- Run
unzip Package.0.1.0.nupkg
, allow the.nuspec
file to be replaced. - Edit the
.nuspec
file and set the version to0.1
- Compress/zip the all of the files in the folder except for
Package.0.1.0.nupkg
. - Rename the zip archive
Package.0.1.nupkg
- Run
- Add a GitLab project to your NuGet sources:
nuget source Add -Name localhost -Source "http://gdk.test:3001/api/v4/projects/<project_id>/packages/nuget/index.json" -UserName <gitlab_username> -Password <personal_access_token>
- Push the package to your project:
nuget push Package.0.1.nupkg -Source localhost
- In the UI, navigate to the project, go to
Packages & Registries -> Package Registry
. You should see the NuGet package published with version0.1
.
If you see the temporary NuGet package in the UI, ensure your background jobs are running.
🛃 MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #342572 (closed)