1

The version of Markdig that comes with powershell is really old, so I wanted to use a newer one

I start a new PS Session

[System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location | Sort-Object -Property FullName | Select-Object -Property FullName, Location, GlobalAssemblyCache, IsFullyTrusted | where {$_.FullName -match 'Markdig'}

and I get no results - great, no markdig loaded to the session - so should be no problems with side-by-side loading.

I get the latest version of Markdig.Signed from Nuget and Add-Type

Add-Type -path .\application\Depend-NuGet\Markdig.Signed\lib\netstandard2.0\Markdig.Signed.dll -Verbose

but it totally ignores me and adds the old one from the powershell\7 folder

[System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location | Sort-Object -Property FullName | Select-Object -Property FullName, Location, GlobalAssemblyCache, IsFullyTrusted | where {$_.FullName -match 'Markdig'}

FullName                                                                           Location                                         GlobalAssemblyCache IsFullyTrusted
--------                                                                           --------                                         ------------------- --------------
Markdig.Signed, Version=0.21.1.0, Culture=neutral, PublicKeyToken=870da25a133885f8 C:\Program Files\PowerShell\7\Markdig.Signed.dll               False           True

So annoying. It would be nice if Add-Type could give a warning or something if it was going to totally ignore what it was asked to do.

Is there any way to solve this?

Brett
  • 719
  • 1
  • 7
  • 19
  • I don't think I make it clear. When I start the PS session, the GetAssemblies() doesn't list Markdig. When I try to add the specific one that I want from the file dll, it adds the one in the net7 folder, not the one I asked for. So I don't think that it is caused by the side-by-side limitation – Brett Mar 16 '22 at 01:08
  • `[System.Reflection.Assembly]::LoadFile($(Convert-Path '.\application\Depend-NuGet\Markdig.Signed\lib\netstandard2.0\Markdig.Signed.dll'))` should do the trick (`LoadFile()` won't attempt any smart resolution or redirection, it'll just load that specific assembly file) – Mathias R. Jessen Mar 16 '22 at 13:03

0 Answers0