Skip to content

Incompatibility with Powershell v3 #1004

Closed
@lipkau

Description

@lipkau

Before submitting a bug report:

Steps to reproduce

In a PSv3 console:

Invoke-ScriptAnalyzer -Path "." -Recurse

Expected behavior

Analyzes the code and returns problems as expected.

Actual behavior

WARNING: System.ComponentModel.Composition.CompositionException: The composition produced a single composition error.
The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

1) Could not load type 'Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache' from assembly
'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Resulting in: An exception occurred while trying to create an instance of type
'Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseIdenticalMandatoryParametersDSC'.

Resulting in: Cannot activate part
'Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseIdenticalMandatoryParametersDSC'.
Element: Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseIdenticalMandatoryParametersDSC -->
Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseIdenticalMandatoryParametersDSC -->  AssemblyCatalog
(Assembly="Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules, Version=1.16.1.0, Culture=neutral,
PublicKeyToken=null")

Resulting in: Cannot get export
'Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseIdenticalMandatoryParametersDSC
(ContractName="Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.IDSCResourceRule")' from part
'Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseIdenticalMandatoryParametersDSC'.
Element: Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseIdenticalMandatoryParametersDSC
(ContractName="Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.IDSCResourceRule") -->
Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseIdenticalMandatoryParametersDSC -->  AssemblyCatalog
(Assembly="Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules, Version=1.16.1.0, Culture=neutral,
PublicKeyToken=null")

Resulting in: Cannot set import 'Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.DSCResourceRules
(ContractName="Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.IDSCResourceRule")' on part
'Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer'.
Element: Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.DSCResourceRules
(ContractName="Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.IDSCResourceRule") -->
Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer

   at System.ComponentModel.Composition.CompositionResult.ThrowOnErrors(AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ComposablePartExportProvider.Compose(CompositionBatch batch)
   at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.LoadRules(Dictionary`2 result,
CommandInvocationIntrinsics invokeCommand, Boolean loadBuiltInRules)
Invoke-ScriptAnalyzer : Exception of type 'System.Exception' was thrown.
At line:1 char:1
+ Invoke-ScriptAnalyzer -Path "." -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceExists: (Microsoft.Windo....ScriptAnalyzer:ScriptAnalyzer) [Invoke-ScriptAnalyze
   r], Exception
    + FullyQualifiedErrorId : Cannot find ScriptAnalyzer rules in the specified path,Microsoft.Windows.PowerShell.Scri
   ptAnalyzer.Commands.InvokeScriptAnalyzerCommand

Environment data

PS C:\Users\TestVM\projects\jiraps> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      3.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.42000
BuildVersion                   6.2.9200.22198
PSCompatibleVersions           {1.0, 2.0, 3.0}
PSRemotingProtocolVersion      2.2


PS C:\Users\TestVM\projects\jiraps> (Get-Module -ListAvailable PSScriptAnalyzer).Version | % {$_.ToString()}
1.16.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions