-
Notifications
You must be signed in to change notification settings - Fork 55
Allow module without version #600
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
Changes from all commits
e8e1180
ee03947
ced2421
8edeb32
b7e94a8
1a488e3
704186d
db4268c
64c8ea9
c090754
b513548
58b9d3d
dd460eb
9fc330a
4b0e9d4
bd42eaf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| @{ | ||
|
|
||
| # Script module or binary module file associated with this manifest. | ||
| RootModule = 'TestClassNoVersion.psm1' | ||
|
|
||
| # Version number of this module. | ||
| ModuleVersion = '0.0.1' | ||
|
|
||
| # Supported PSEditions | ||
| # CompatiblePSEditions = @() | ||
|
|
||
| # ID used to uniquely identify this module | ||
| GUID = 'ec985d60-82f4-4d45-83e0-b6f935654350' | ||
|
|
||
| # Author of this module | ||
| Author = 'Microsoft' | ||
|
|
||
| # Company or vendor of this module | ||
| CompanyName = 'Microsoft Corporation' | ||
|
|
||
| # Copyright statement for this module | ||
| Copyright = '(c) Microsoft. All rights reserved.' | ||
|
|
||
| # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. | ||
| FunctionsToExport = @() | ||
|
|
||
| # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. | ||
| CmdletsToExport = @() | ||
|
|
||
| # Variables to export from this module | ||
| VariablesToExport = @() | ||
|
|
||
| # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. | ||
| AliasesToExport = @() | ||
|
|
||
| # DSC resources to export from this module | ||
| DscResourcesToExport = 'TestClassNoVersion' | ||
|
|
||
| # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. | ||
| PrivateData = @{ | ||
|
|
||
| PSData = @{ | ||
| DscCapabilities = @('Get', 'Test', 'Set') | ||
|
|
||
| } # End of PSData hashtable | ||
|
|
||
| } # End of PrivateData hashtable | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| [DscResource()] | ||
| class TestClassNoVersion | ||
| { | ||
| [DscProperty(Key)] | ||
| [string] $Name | ||
|
|
||
| [void] Set() | ||
| { | ||
| } | ||
|
|
||
| [bool] Test() | ||
| { | ||
| return $true | ||
| } | ||
|
|
||
| [TestClassNoVersion] Get() | ||
| { | ||
| return $this | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,15 +32,17 @@ function Get-DSCResourceModules | |
| { | ||
| continue | ||
| } | ||
| # Partially re-used code from the original DSCv2 Get-DSCResource code | ||
| # Get-Module -ListAvailable is slow and has a bug causing incorrect reporting | ||
| $moduleFolders = Get-ChildItem $folder -Directory | ||
| if (-not $moduleFolders) { | ||
| $moduleFolders = Get-ChildItem (Split-Path $folder -Parent) | Where-Object { $_.Name -eq (Split-Path $folder -Leaf) } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When working in the winget-dsc repository, I often found myself doing something like: $env:PSModulePath += ";C:\source\winget-dsc\resources\Microsoft.DotNet.Dsc"
# Call function
Get-DscResourcesModules
# Old code did not list out the moduleHope that sheds some light on it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please post an output of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you; in the right picture - what is the full path to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the explanation, Andrew. I tried it in the past, and that works. But sometimes, I want only particular modules to be found, with the structure mentioned in this PR and in the test. What are your thoughts on those?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Gijsreyn I think the problem is that this is contrary to how module discovery works with PS7 and it would be preferable to not deviate from that. Is this only for development purposes or do you have a real scenario where you want to limit the discovery?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can understand, and this was the use case. Feel free to abandon the pull request. I appreciated the time you guys looked into it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @SteveL-MSFT. After testing for a while, I got a scenario that breaks the current testing cycle. Imagine the following use case found while developing in winget-dsc. To test out both cases by either using When modules are being discovered in the lower levels, so say C:\source\winget-dsc\resources\NpmDsc, it correctly loads the PS C:\Users\User> $env:PSModulePath += ";C:\source\winget-dsc\resources\Microsoft.Windows.Setting.Language" I know you've closed down the ticket, but perhaps we can still consider it. Thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Gijsreyn Please open a new issue and copy-paste your last post there. |
||
| } | ||
|
|
||
| foreach($moduleFolder in Get-ChildItem $folder -Directory) | ||
| { | ||
| $addModule = $false | ||
| foreach($psd1 in Get-ChildItem -Recurse -Filter "$($moduleFolder.Name).psd1" -Path $moduleFolder.fullname -Depth 2) | ||
| { | ||
| $containsDSCResource = select-string -LiteralPath $psd1 -pattern '^[^#]*\bDscResourcesToExport\b.*' | ||
| if($null -ne $containsDSCResource) | ||
| { | ||
| foreach ($moduleFolder in $moduleFolders) { | ||
| foreach ($psd1 in Get-ChildItem -Recurse -Filter "$($moduleFolder.Name).psd1" -Path $moduleFolder.fullname -Depth 2) { | ||
| $containsDSCResource = Select-String -LiteralPath $psd1 -Pattern '^[^#]*\bDscResourcesToExport\b.*' | ||
| if ($null -ne $containsDSCResource) { | ||
| $dscModulePsd1List.Add($psd1) | Out-Null | ||
| } | ||
| } | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.