When running Desired State Configuration command:
Start-DSCConfiguration -ComputerName localhost -Path ./CsharpExample -Verbose -Wait -Force
We get the following error:
InvalidOperation: Importing module cSharpDSCResource failed with error - Could not load file or assembly 'System.Management.Automation, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
The directory structure to the dll:
"C:\Program Files\WindowsPowerShell\Modules\cSharpDSCResource\DSCResources\cSharpDSCResource\cSharpDSCResource.dll"
[appdomain]::CurrentDomain.GetAssemblies() | Sort-Object -Property FullName | Select-Object -Property FullName; returns from $PSVersionTable.PSVersion 5 prompt:
System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
[appdomain]::CurrentDomain.GetAssemblies() | Sort-Object -Property FullName | Select-Object -Property FullName; returns from $PSVersionTable.PSVersion 7 prompt:
System.Management.Automation, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
We can't figure out why it cannot find or load System.Management.Automation 7.1.0.0
Get-DSCResource Returns:
Binary cSharpDSCResource cSharpDSCResource 0.0.1 {Path, Content, DependsOn, Ensure...}
We are using windows management framework:
Microsoft Net SDK 5.0.101
Code for project in visual studio code:
cSharpDSCresource.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Management.Automation" Version="7.1.0" />
</ItemGroup>