Skip to content

SaveDscDependency switch does not work when Import-DscResource specifies ModuleVersion #1079

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

Closed
ArturDorochowicz opened this issue Oct 9, 2018 · 1 comment · Fixed by #1094
Assignees
Milestone

Comments

@ArturDorochowicz
Copy link

Steps to reproduce

Create a DSC configuration that imports a specific module version which happens to not be the newest one (at the time of writing the newest one for the module imported is 8.4.0.0):

# Cfg.ps1
configuration Cfg {
  Import-DscResource -ModuleName xPSDesiredStateConfiguration -ModuleVersion '8.3.0.0'
}

Invoke PSScriptAnalyzer with SaveDscDependency switch:

Invoke-ScriptAnalyzer -SaveDscDependency -Path ./Cfg.ps1

It fails with Parse error in file ...: Cound not find the module '<xPSDesiredStateConfiguration, 8.3.0.0>'... error.

Expected behavior

PSScriptAnalyzer should use the specified version of the module.

Actual behavior

PSScriptAnalyzer appears to only retrieve the newest version of the module. As soon as there's a newer version than specified available, the invocation breaks.

Environment data

This is with PSScriptAnalyzer version 1.17.1.

After looking at the implementation, I'm pretty sure that the module specification syntax doesn't work either: –ModuleName @{ModuleName="xPSDesiredStateConfiguration";ModuleVersion="8.3.0.0"}.

@bergmeister
Copy link
Collaborator

bergmeister commented Nov 3, 2018

I can confirm this happens and will look into it, using the -Verbose switch, I see that PSSA downloads the latest version at the moment. The code in ModuleDependencyHandlere.cs shows that downloading a specific version is a feature that is not implemented yet. We would definitely accept a PR for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants