Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save-PSResource doesn't install the correct version. #1657

Open
5 tasks done
ADD-Izan-Garcia opened this issue May 20, 2024 · 5 comments
Open
5 tasks done

Save-PSResource doesn't install the correct version. #1657

ADD-Izan-Garcia opened this issue May 20, 2024 · 5 comments
Assignees

Comments

@ADD-Izan-Garcia
Copy link

Prerequisites

Steps to reproduce

I am experiencing a problem with Save-PSResource. When installing a specific version of a module from a NuGet server, it doesn't take the one specified.
Steps to reproduce:

  1. Have one powershell module in a NuGet server with two different versions published, like '2024.5.20.1' and 2024.5.20.12'
  2. Download the module with the cmdlet:
Save-PSResource -Name ExampleModule -Version [2024.5.20.1] -Repository ExampleRepository -Path  C:\Users\ExampleUser\Documents -SkipDependencyCheck

Expected behavior

ExampleModule installed in:
C:\Users\ExampleUser\Documents\ExampleModule\2024.5.20.1\ExampleModule.psd1
C:\Users\ExampleUser\Documents\ExampleModule\2024.5.20.1\ExampleModule.psm1 

Inside the ExampleModule.psd1, the field ModuleVersion with the correct version, in this case '2024.5.20.1'

Actual behavior

ExampleModule installed in:
C:\Users\ExampleUser\Documents\ExampleModule\2024.5.20.1\ExampleModule.psd1
C:\Users\ExampleUser\Documents\ExampleModule\2024.5.20.1\ExampleModule.psm1 

Inside the ExampleModule.psd1, the field ModuleVersion with an incorrect version, in this case '2024.5.20.12'

Error details

No response

Environment data

PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.20348
Platfor Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0....}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Visuals

No response

@237dmitry
Copy link

I could not reproduce:

$ Save-PSResource -Name PSWSMan -Version 2.3.0 -Path ./Downloads/ -IncludeXml
$ tree -d ./Downloads/PSWSMan/
./Downloads/PSWSMan/
└── 2.3.0
    ├── bin
    │   ├── glibc-1.0
    │   ├── glibc-1.1
    │   ├── glibc-3
    │   ├── macOS-1.1
    │   ├── macOS-3
    │   ├── musl-1.1
    │   └── musl-3
    └── en-US

@ADD-Izan-Garcia
Copy link
Author

Its not the same scenario. I think the problem is that instead of taking the version '2024.5.20.1' as exact version, is taking it as minimum version. That's why then the version '2024.5.20.12' is taken.

@237dmitry
Copy link

Its not the same scenario.

A did not find modules with similar versions:

$ Save-PSResource -Name PSWriteColor -Version 0.7 -Path ./Downloads/ -IncludeXml
$ Save-PSResource -Name PSWriteColor -Version 0.71 -Path ./Downloads/ -IncludeXml
$ (dir ./Downloads/PSWriteColor/).Name
0.7
0.71

@daxian-dbw daxian-dbw transferred this issue from PowerShell/PowerShell May 20, 2024
@mklement0
Copy link

mklement0 commented May 20, 2024

I also cannot reproduce the problem, at least with the PSWriteColor module.

The -Version parameter is explicitly documented as being version-exact (no need for [...] enclosure), and that to get the minimum-compatible-version behavior you'd have to use something like '[1.0.0,]' (note the comma).

@mklement0
Copy link

On second thought:

  • The Package Versioning rules seem to be based on semver version numbers, which are limited to three components, with an optional suffix.

  • Therefore, 2024.5.20.1 is not a valid semver ([semver]) version number (but is a valid [version] number).

I wonder if the problem is related to that, and how such invalid-as-semver version numbers are de facto / should be handled.

@anamnavi anamnavi self-assigned this May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants