diff --git a/src/AnyPackage.PowerShellGet.psd1 b/src/AnyPackage.PowerShellGet.psd1 index fcd74cd..5c786da 100644 --- a/src/AnyPackage.PowerShellGet.psd1 +++ b/src/AnyPackage.PowerShellGet.psd1 @@ -7,7 +7,9 @@ Copyright = '(c) 2023 Thomas Nieto. All rights reserved.' Description = 'PowerShellGet provider for AnyPackage.' PowerShellVersion = '5.1' - RequiredModules = @('AnyPackage', 'PowerShellGet') + RequiredModules = @( + @{ ModuleName = 'AnyPackage'; ModuleVersion = '0.4.1' }, + 'PowerShellGet') FunctionsToExport = @() CmdletsToExport = @() AliasesToExport = @() diff --git a/src/AnyPackage.PowerShellGet.psm1 b/src/AnyPackage.PowerShellGet.psm1 index 5e92a89..a5a4d2d 100644 --- a/src/AnyPackage.PowerShellGet.psm1 +++ b/src/AnyPackage.PowerShellGet.psm1 @@ -521,7 +521,8 @@ function Write-Package { $deps = [List[PackageDependency]]::new() foreach ($dep in $resource.Dependencies) { - $dependency = [PackageDependency]::new($dep.Name, $dep.VersionRange) + $versionRange = [PackageVersionRange]::new($dep.VersionRange, $true) + $dependency = [PackageDependency]::new($dep.Name, $versionRange) $deps.Add($dependency) } @@ -535,7 +536,12 @@ function Write-Package { $version = $resource.Version.ToString() if ($resource.Prerelease) { - $version = $version + '-' + $resource.Prerelease + # Version property is incorrect for 2 and 3 digits + # https://github.com/PowerShell/PowerShellGet/issues/697 + $version = "{0}.{1}.{2}-{3}" -f $resource.Version.Major, + $resource.Version.Minor, + $resource.Version.Build, + $resource.Prerelease } $request.WritePackage($resource.Name, $version, $resource.Description, $source, $ht, $deps) diff --git a/test/Find-Package.Tests.ps1 b/test/Find-Package.Tests.ps1 index 8155506..5b4752e 100644 --- a/test/Find-Package.Tests.ps1 +++ b/test/Find-Package.Tests.ps1 @@ -19,7 +19,7 @@ Describe Find-Package { Context 'with -Version parameter' { It 'should return value' { $package = Find-PSResource -Name AnyPackage - Find-Package -Name AnyPackage -Version $package.Version | + Find-Package -Name AnyPackage -Version $package.Version.ToString() | Should -Not -BeNullOrEmpty }