My binary PowerShell module fails to load when using other assemblies

Problem:

When I try to import my binary module it fails to load because it can’t find a dependency.

Import-Module: Could not load file or assembly 'System.IO.Abstractions, Version=12.0.0.0, Culture=neutral, PublicKeyToken=96bf224d23c43e59'. The system cannot find the file specified.

image

Solution:

Open your csproj for your module and add the following to a PropertyGroup element.

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
For my project I added to the first one I found.
<PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AssemblyName>Trackyon.PSBuild</AssemblyName>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

Now I can import my module as expected.

image

Add comment

Loading