When creating task involving Microsoft.Powershell.PlatyPS, assembly Markdig.Signed could not be loaded.
Task("ImportPlatyPS")
.Description("Test importing Microsoft.Powershell.PlatyPS")
.Does(() =>
{
StartPowershellScript(
@"Write-Host ""Test Successfull""", new PowershellSettings()
.WithModule("Microsoft.Powershell.PlatyPS")
.OutputToAppConsole(true)
);
});
.\build.ps1 --Target=ImportPlatyPS
An error occurred when executing task 'ImportPlatyPS'.
Error: Failed to Execute Powershell Script: System.Management.Automation.CmdletInvocationException: Could not load file or assembly 'Markdig.Signed, Version=0.33.0.0, Culture=neutral, PublicKeyToken=870da25a133885f8'. Assembly with same name is already loaded
---> System.IO.FileLoadException: Could not load file or assembly 'Markdig.Signed, Version=0.33.0.0, Culture=neutral, PublicKeyToken=870da25a133885f8'. Assembly with same name is already loaded
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(PSModuleInfo parentModule, String moduleName, String fileName, Assembly assemblyToLoad, String moduleBase, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, String prefix, Boolean& found, String shortModuleName, Boolean disableFormatUpdates)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(PSModuleInfo parentModule, String moduleName, String fileName, Assembly assemblyToLoad, String moduleBase, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, String prefix, Boolean& found)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(PSModuleInfo parentModule, String fileName, String moduleBase, String prefix, SessionState ss, Object privateData, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleNamedInManifest(PSModuleInfo parentModule, ModuleSpecification moduleSpecification, String moduleBase, Boolean searchModulePath, String prefix, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, Object privateData, Boolean& found, String shortModuleName, Nullable`1 manifestLanguageMode)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions& options, Boolean& containedErrors)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(ExternalScriptInfo scriptInfo, ManifestProcessingFlags manifestProcessingFlags, Version
minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions& options)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(PSModuleInfo parentModule, String fileName, String moduleBase, String prefix, SessionState ss, Object privateData, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadUsingExtensions(PSModuleInfo parentModule, String moduleName, String fileBaseName, String extension, String moduleBase, String prefix, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadUsingExtensions(PSModuleInfo parentModule, String moduleName, String fileBaseName, String extension, String moduleBase, String prefix, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadUsingMultiVersionModuleBase(String moduleBase, ManifestProcessingFlags manifestProcessingFlags, ImportModuleOptions importModuleOptions, Boolean& found)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadUsingModulePath(PSModuleInfo parentModule, IEnumerable`1 modulePath, String name, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, PSModuleInfo& module)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadUsingModulePath(IEnumerable`1 modulePath, String name, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, PSModuleInfo& module)
at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions importModuleOptions, String name)
at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName_WithTelemetry(ImportModuleOptions importModuleOptions, String name)
at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()
at System.Management.Automation.Cmdlet.DoProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
--- End of inner exception stack trace ---
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
at System.Management.Automation.DlrScriptCommandProcessor.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
--- End of stack trace from previous location ---
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc() (Could not load file or assembly 'Markdig.Signed, Version=0.33.0.0, Culture=neutral, PublicKeyToken=870da25a133885f8'. Assembly with same name is already loaded)
Could not load file or assembly 'Markdig.Signed, Version=0.33.0.0, Culture=neutral, PublicKeyToken=870da25a133885f8'. Assembly with same name is already loaded
As far as I understand, the problem is that binary modules are loaded into the same default Assembly Load Context (ALC).
A potential solution might be to isolate dependencies to prevent conflicts with other modules.
I should note that I was only able to use Cake.Powershell successfully by using the directive:
#addin nuget:?package=Cake.Powershell&version=4.0.0&loaddependencies=true
Otherwise, I encountered the problem described in this issue.
Problem
When creating task involving Microsoft.Powershell.PlatyPS, assembly Markdig.Signed could not be loaded.
Steps to reproduce
Create UpdateHelpFiles Task
Then run task
Expected behaviour
Output "Test Successfull"
Actual behaviour
As far as I understand, the problem is that binary modules are loaded into the same default Assembly Load Context (ALC).
A potential solution might be to isolate dependencies to prevent conflicts with other modules.
I should note that I was only able to use Cake.Powershell successfully by using the directive:
#addin nuget:?package=Cake.Powershell&version=4.0.0&loaddependencies=true
Otherwise, I encountered the problem described in this issue.