Skip to content

Update nuget version regex

Steve Abrams requested to merge 342572-nuget-regex-short into master

📙 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

Screen_Shot_2022-01-04_at_3.58.48_PM

🗒 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.

  1. Ensure you have the NuGet CLI installed (see nuget docs for links to installation pages).
  2. In a new directory, run nuget spec.
  3. Update version in the Package.nuspec to be 0.1.
  4. Run nuget pack to generate a Package.0.1.0.nupkg file.
  5. Notice the NuGet CLI automatically updated the version to 0.1.0, we need to update the version manually:
    1. Run unzip Package.0.1.0.nupkg, allow the .nuspec file to be replaced.
    2. Edit the .nuspec file and set the version to 0.1
    3. Compress/zip the all of the files in the folder except for Package.0.1.0.nupkg.
    4. Rename the zip archive Package.0.1.nupkg
  6. 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>
  7. Push the package to your project:
    nuget push Package.0.1.nupkg -Source localhost
  8. In the UI, navigate to the project, go to Packages & Registries -> Package Registry. You should see the NuGet package published with version 0.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.

Related to #342572 (closed)

Edited by Steve Abrams

Merge request reports