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

#Requires statement does not work in Psake script #294

Open
GreatTeacherBasshead opened this issue Mar 30, 2020 · 3 comments
Open

#Requires statement does not work in Psake script #294

GreatTeacherBasshead opened this issue Mar 30, 2020 · 3 comments
Assignees

Comments

@GreatTeacherBasshead
Copy link

GreatTeacherBasshead commented Mar 30, 2020

I have a PSake script:
#Requires -Modules @{ModuleName='dependent'; RequiredVersion='1.0.0'}
Task Show {Show-Version}

And 2 modules (2 versions). One depends on another:

  • dependent
    1.0.0:
    psm1: function Show-Version {Show-VersionBase}
    psd1: RequiredModules = @(@{ModuleName = 'main'; RequiredVersion = '1.0.0'})
    2.0.0:
    psm1: function Show-Version {Show-VersionBase}
    psd1: RequiredModules = @(@{ModuleName = 'main'; RequiredVersion = '2.0.0'})

  • main
    1.0.0 : function Show-VersionBase {"1.0.0"}
    2.0.0 : function Show-VersionBase {"2.0.0"}

Expected Behavior

It outputs "1.0.0"

Current Behavior

It outputs "2.0.0"

Context

I have different versions of modules deployed on a build server. Psake takes the latest version, instead of 'required' one, causing failures.

This perfectly works when using plain powershell:
#Requires -Modules @{ModuleName='dependent'; RequiredVersion='1.0.0'}
Show-Version

Your Environment

  • Module version used: 4.9.0
  • Operating System version: Win10/Win2016
  • PowerShell version: 5.1
@devblackops devblackops self-assigned this Apr 12, 2020
@devblackops
Copy link
Member

devblackops commented Apr 12, 2020

Thanks for the issue @GreatTeacherBasshead. I can repo this, but the cause isn't immediately obvious. I suspect we have some funny things with scoping going on.

@stale
Copy link

stale bot commented Jun 11, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 11, 2020
@GreatTeacherBasshead
Copy link
Author

Ehm... I believe if it closed once, it wouldn't be reopened again. So adding this comment to make it live...

@stale stale bot removed the stale label Jun 12, 2020
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

2 participants