gaelcolas / Sampler

Module template with build pipeline and examples, including DSC elements.
MIT License
171 stars 42 forks source link

Improve script `Resolve-Dependency.ps1` #419

Closed johlju closed 1 year ago

johlju commented 1 year ago

Pull Request

Pull Request (PR) description

Changed

Fixed

Task list


This change is Reviewable

johlju commented 1 year ago

@gaelcolas There were a lot of issue running the pipeline script in Windows PowerShell on a newly installed Windows 11. This change solves all the issues I found. I will also update the guide at dscommunity.org.

codecov[bot] commented 1 year ago

Codecov Report

Merging #419 (36b3470) into main (91f40fe) will increase coverage by 0%. The diff coverage is 100%.

Impacted file tree graph

@@         Coverage Diff         @@
##           main   #419   +/-   ##
===================================
  Coverage    81%    81%           
===================================
  Files        44     44           
  Lines      2317   2319    +2     
===================================
+ Hits       1897   1899    +2     
  Misses      420    420           
Impacted Files Coverage Δ
Sampler/suffix.ps1 100% <100%> (ø)
johlju commented 1 year ago

Although, there is one issue I cannot solve in Windows PowerShell, I will document it instead.

After PowerShellGet 2.2.5 and new PackageManagement is saved it is not possible to resolve pre-release dependencies other than starting a fresh session. Even after removing the PowerShellGet and PackageMangement module (and I verified none was imported in session) and importing the latest version of both module PowerShellGet still uses the old PackageManagement module. It results in the error
Find-Module : A parameter cannot be found that matches parameter name 'AllowPrereleaseVersions' because PowerShellGet calls Find-Package in the old version. After restarting the session the build script works like it should again. Very annoying. I can't figure out what keeps the old version lingering around when it is not loaded into the session. Only conclusion is that it is an assembly that is loaded that does not get removed (becuase it can't remove assemblies) when removing the module PackageManagement.

This is only an issue for repos that has pre-releases specified in RequiredModules.ps1.

johlju commented 1 year ago

Added PR https://github.com/dsccommunity/dsccommunity.org/pull/209 to change the docs.

johlju commented 1 year ago

Fixed thd comments, ready for review again. 🙂

johlju commented 1 year ago

.... but build is failing, probably due to new ModuleBuilder... 😞

johlju commented 1 year ago

Added a fix for the aliases since the module creates aliases dynamically during import and should not define them in module manifest.

gaelcolas commented 1 year ago

Even after removing the PowerShellGet and PackageMangement module and importing the latest version of both module PowerShellGet still uses the old PackageManagement module.

Yep, just looked at that and I can't find a way either. Wonder if we should make the checks/bootstrap on another runspace so that when we're done we can directly import the correct version. I don't know how practical that would be though.

johlju commented 1 year ago

Maybe it is possible to do this as the first step and do it in a Start-Job so that the install module stuff runs in other session 🤔 I could give it a try. Not sure how runspaces works so will need to investigate. Would be great to find a solution, because its a bit annoying to have that "bug". 🙂

johlju commented 1 year ago

@gaelcolas I started looking at it, but then I saw that the new preview of PowerShellGet v3 remove the dependence on NuGet. So I'm thinking we merge tis as-is, then instead work on implementing support for PSGet v3 preview instead.

gaelcolas commented 1 year ago

Good point. Will also talk to you later about this.