PowerShell / PackageManagementProviderResource

Modules with DSC resources for the PackageManagement(aka OneGet) providers.
MIT License
37 stars 24 forks source link

Having Desktop and Core installed breaks PackageManagement #44

Open kfsone opened 1 year ago

kfsone commented 1 year ago

Prerequisites

Steps to reproduce

Having both Desktop and Core installed results in there being two versions of PackageManagement, Desktop 1.0.0.1 and Core 1.4.8.1, but Import-DscResource isn't smart enough to distinguish between editions.

I thought that perhaps it would be possible to get the version of the correct edition, but instead I'm having to hardcode 1.0.0.1 everywhere, because Import-DscResource ... -ModuleVersion has to be a constant.

Expected behavior

PS> Configuration HailMary { Import-DscResource -ModuleName PackageManagement }
PS>

Actual behavior

PS> Configuration HailMary { Import-DscResource -ModuleName PackageManagement }
ParserError:
Line |
   1 |  … uration HailMary { Import-DscResource -ModuleName PackageManagement }
     |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Multiple versions of the module 'PackageManagement' were found. You can run 'Get-Module -ListAvailable
     | -FullyQualifiedName PackageManagement' to see available versions on the system, and then use the fully
     | qualified name '@{ModuleName="PackageManagement"; RequiredVersion="Version"}'.

Error details

PS> Configuration HailMary { Import-DscResource -ModuleName PackageManagement }
ParserError:
Line |
   1 |  … uration HailMary { Import-DscResource -ModuleName PackageManagement }
     |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Multiple versions of the module 'PackageManagement' were found. You can run 'Get-Module -ListAvailable
     | -FullyQualifiedName PackageManagement' to see available versions on the system, and then use the fully qualified
     | name '@{ModuleName="PackageManagement"; RequiredVersion="Version"}'.

10/31/2022 15:37:56 [C:\Users\oliver]
Win|PS> get-error

Type        : System.Management.Automation.ParseException
Errors      :
    Extent  : Import-DscResource -ModuleName PackageManagement
    ErrorId : MultipleModuleEntriesFoundDuringParse
    Message : Multiple versions of the module 'PackageManagement' were found. You can run 'Get-Module -ListAvailable
-FullyQualifiedName PackageManagement' to see available versions on the system, and then use the fully qualified name
'@{ModuleName="PackageManagement"; RequiredVersion="Version"}'.
Message     : At line:1 char:26
              + … uration HailMary { Import-DscResource -ModuleName PackageManagement }
              +                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              Multiple versions of the module 'PackageManagement' were found. You can run 'Get-Module -ListAvailable
-FullyQualifiedName PackageManagement' to see available versions on the system, and then use the fully qualified name
'@{ModuleName="PackageManagement"; RequiredVersion="Version"}'.
ErrorRecord :
    Exception             :
        Type    : System.Management.Automation.ParentContainsErrorRecordException
        Message : At line:1 char:26
                  + … uration HailMary { Import-DscResource -ModuleName PackageManagement }
                  +                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  Multiple versions of the module 'PackageManagement' were found. You can run 'Get-Module
-ListAvailable -FullyQualifiedName PackageManagement' to see available versions on the system, and then use the fully
qualified name '@{ModuleName="PackageManagement"; RequiredVersion="Version"}'.
        HResult : -2146233087
    CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    FullyQualifiedErrorId : MultipleModuleEntriesFoundDuringParse
    InvocationInfo        :
        ScriptLineNumber : 1
        OffsetInLine     : 26
        HistoryId        : -1
        Line             : Configuration HailMary { Import-DscResource -ModuleName PackageManagement }
        PositionMessage  : At line:1 char:26
                           + … uration HailMary { Import-DscResource -ModuleName PackageManagement }
                           +                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        CommandOrigin    : Internal
TargetSite  :
    Name          : Invoke
    DeclaringType : System.Management.Automation.Runspaces.PipelineBase, System.Management.Automation,
Version=7.2.7.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    MemberType    : Method
    Module        : System.Management.Automation.dll
Source      : System.Management.Automation
HResult     : -2146233087
StackTrace  :
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.Runspaces.Pipeline.Invoke()
   at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown,
ExecutionOptions options)

Environment data

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.7
PSEdition                      Core
GitCommitId                    7.2.7
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.22000.832
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22000.832
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Version

7.2.7

Visuals

No response