microsoft / winget-cli-restsource

This project aims to provide a reference implementation for creating a REST based package source for the winget client.
MIT License
241 stars 62 forks source link

properly version the Microsoft.WinGet.Source PowerShell module #255

Open 3limin4t0r opened 3 weeks ago

3limin4t0r commented 3 weeks ago

Description of the new feature / enhancement

At the moment the version of Microsoft.WinGet.Source is set to 0.1.0 which is the default when the definition file is generated.

https://github.com/microsoft/winget-cli-restsource/blob/05d4836affcc6970957bb03b67e26914113438e9/Tools/PowershellModule/src/Microsoft.WinGet.Source.psd1#L17

I suggest that this version mirrors the release version of this repository. (see releases) For example, the version should be set to 1.1.20230906. Which is the newest release at the time of writing this issue.

The reason I'm proposing this change is to simplify installing multiple versions of the PowerShell module. (see: Installing Multiple Versions of a Module)

Proposed technical implementation details

Let's look at the following scenario:

If you open up a new PowerShell window the module is not loaded, nor can you load it with the Import-Module Microsoft.WinGet.Source command. The reason the module cannot be loaded is because 1.1.20230906 in the path doesn't match the version that is defined in Microsoft.WinGet.Source.psd1.

Of course there would be the option to rename the directory to 0.1.0 instead, but if a future release does not update this version it will conflict with previous a previously installed version. The current solution is to edit the Microsoft.WinGet.Source.psm1 file and manually set the version to 1.1.20230906. This correctly loads the Microsoft.WinGet.Source when opening a new PowerShell window. However in my opinion it's the job of the repository maintainers to correctly set this version when publishing a release.

As a side note it would also be nice if the contents of the .zip folder looks like this:

WinGet.RestSource-Winget.PowerShell.Source.zip
└╴Microsoft.WinGet.Source\
  └╴1.1.20230906\  <- {release version}
    ├╴Microsoft.WinGet.Source.psd1 <- containing: ModuleVersion = {release version}
    ├╴Microsoft.WinGet.Source.psm1
    └╴Library\*

This would allow users to simply drag-n-drop the Microsoft.WinGet.Source directory to their "$([Environment]::GetFolderPath('MyDocuments'))\PowerShell\Modules\" directory to install the module without conflicting with previous installed versions (with the exception of a single Microsoft.WinGet.Source directory merge).

denelon commented 3 weeks ago

We're working on the Entra ID authentication support, and as a part of this I'm anticipating setting up the build pipeline so we can sign and publish the module to the PowerShell gallery. We're looking at versioning as a part of the release process which should address the issue you're having.

Thanks for bringing this up!